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

      

     

  • 相关阅读:
    V2热帖:要多健壮的代码才能支撑起千变万化的需求?
    jmeter生成html报告的命令
    jmeter5.x&4.x搭配使用Serveragent 监听服务端性能参数
    springboot关于tomcat的几个默认配置
    nginx日志统计分析-shell
    OpenStack虚拟机VIP配置步骤
    openstack 3.14.3 虚拟机增加指定IP网卡
    OpenStack各组件的常用命令
    Filebeat的Registry文件解读
    一个shell脚本的实践
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4333462.html
Copyright © 2011-2022 走看看