• 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;
    }
    

      

     

  • 相关阅读:
    数组里面为对象根据某一属性排序
    理由<a>标签跳转到对应锚点
    jquery对复选框选中
    Fullcalendar
    es6学习
    vue 关于树杈图问题
    input 复选框样式修改
    GAMES101 作业2
    一份自己iOS 面试题,拿到15K35K,分享出来
    Cesium 一款面向三维地球和地图的,世界级的JavaScript开源产品
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4333462.html
Copyright © 2020-2023  润新知