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

      

     

  • 相关阅读:
    10分钟轻松设置出 A+ 评分的 HTTP/2 网站
    GGSN与SGSN简介
    cocos游戏开发小白教程网站
    cocos2d-x JS 字符串
    cocos2d-x android工程接入第三方支付宝SDK
    pyCharm编辑器激活使用
    cocos2d-x C++ iOS工程集成第三方支付宝支付功能
    (已解决)在linux的虚拟机上安装vmware tools(实现windows与虚拟机之间的文件交互复制粘贴)
    虚拟机 liunx系统以 root 身份登录权限
    mac系统搭建SVN版本控制
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4333462.html
Copyright © 2020-2023  润新知