zoukankan      html  css  js  c++  java
  • Day2

    1  Button 手写代码生产的方式

    -(void)viewDidLoad
    {
        [super viewDidLoad];
        
        UIButton *btn = [[UIButton alloc]init];
        btn.frame = CGRectMake(0, 100, 100, 100);
        [btn setTitle:@"click" forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        
        UIImage *image = [UIImage imageNamed:@"btn_01"];
        [btn setBackgroundImage:image forState:UIControlStateNormal];
        
        [btn setBackgroundImage:[UIImage imageNamed:@"btn_02"] forState:UIControlStateHighlighted];
        
        [self.view addSubview:btn];
        
    }
    

      

    //添加button点击事件  self.click方法
    [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    

     

    self.headImageView = btn;//相当于连线 监听方法连线 
    

    2 Label  Image Button 手写代码生成以及其他属性的设置

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        
        //标签描述
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, 320, 40)];
        label.text = @"1/5";
        label.textAlignment = NSTextAlignmentCenter;
        [self.view addSubview:label];
        self.noLabel = label;
        
        //图片
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(60, 70, 200, 200)];
        imageView.image = [UIImage imageNamed:@"biaoqingdi"];
        [self.view addSubview:imageView];
        self.icon = imageView;
        
        //图片描述
        UILabel *iconLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 300, 320, 80)];
        iconLabel.text = @"什么表情都弱爆了";
        iconLabel.textAlignment = NSTextAlignmentCenter;//居中
        [self.view addSubview:iconLabel];
        self.descriptionLabel = iconLabel;
        
        //left icon
        UIButton *leftBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
        leftBtn.center = CGPointMake(self.icon.frame.origin.x/2, self.icon.center.y);
        [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_normal"] forState:UIControlStateNormal];
        [self.view addSubview:leftBtn];
        self.leftButton = leftBtn;
        
        //right btn
        UIButton *rightBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 40, 40)];
        rightBtn.center = CGPointMake(self.view.frame.size.width- self.icon.frame.origin.x/2, self.icon.center.y);
        [rightBtn setBackgroundImage:[UIImage imageNamed:@"right_normal"] forState:UIControlStateNormal];
        [self.view addSubview:rightBtn];
        self.leftButton = rightBtn;
    }
    

      

     

  • 相关阅读:
    多线程-threading模块3
    多线程-threading模块2
    多线程-threading模块
    mac下载模块时报错OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/chardet'
    python+selenium高亮显示正在操作的页面元素
    判断元素是否存在页面的两种不同写法
    [转]Python+Selenium之expected_conditions:各种判断(上)
    MACE移植要求
    采用Tensorflow内部函数直接对模型进行冻结
    如何正确可视化RAW(ARW,DNG,raw等格式)图像?
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4333462.html
Copyright © 2011-2022 走看看