zoukankan      html  css  js  c++  java
  • iOS UIButton属性

    UIButton类型:

        UIButtonTypeCustom                 // 自定义类型  

        UIButtonTypeSystem                

        UIButtonTypeDetailDisclosure   //细节展示按钮

        UIButtonTypeInfoLight            //浅色背景的信息按钮

        UIButtonTypeInfoDark            //暗色背景的信息按钮

        UIButtonTypeContactAdd       //添加按钮

        UIButtonTypeRoundedRect = UIButtonTypeSystem    //圆角矩形

    UIButton状态:   

        UIControlStateNormal       = 0,                //正常状态

        UIControlStateHighlighted  = 1 << 0,      //高亮状态               

        UIControlStateSelected     = 1 << 2,      //选中状态          

        UIControlStateApplication                     //

        UIControlStateReserved                       //保留状态

        UIControlStateDisabled                       //禁用状态

      //创建btn 

        UIButton * btn =[UIButton buttonWithType:UIButtonTypeCustom];

    //坐标    

        btn.frame =CGRectMake(x, y, width, height);

    //标题                                       

        [btn setTitle:@"请选择" forState:UIControlStateNormal];

    //字体大小                  

        btn.titleLabel.font=[UIFont boldSystemFontOfSize:14.0f];  

    //背景颜色              

        btn.backgroundColor=[UIColor lightGrayColor];  

    //标题颜色                           

        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    //背景图片  

        [btn setBackgroundImage:newImage  forState:UIControlStateNormal];

    //填充图片   

        [btn setImage:[UIImage imageNamed:@"btng.png"] forState:UIControlStateNormal];     

     //btn触发事件,调下一个方法

        [btn addTarget:self action:@selector(btnChu) forControlEvents:UIControlEventTouchUpInside];

     //把btn放在view上

        [self.view addSubview:btn];    

        

       /*    1 默认情况下按钮高亮,图像颜色深,如果btn.adjustsImageWhenHighlighted=NO;可以去掉这个功能

              2禁用:btn.adjustsImageWhenDisabled=NO;

              3按钮按下发亮:btn.showsTouchWhenHighlighted=YES;

       */

  • 相关阅读:
    我为什么要选择RabbitMQ ,RabbitMQ简介,各种MQ选型对比(转载)
    spring boot 使用application.properties 进行外部配置
    Nginx+Springboot+Vue 前后端分离 解决跨域问题
    windows7下RabbitMQ的安装
    七牛云 如何配置域名的 CNAME
    springboot接口 接收参数为实体对象跟MultipartFile对象报错。
    数据库性能优化之SQL语句优化(下)
    数据库性能优化之SQL语句优化(上)
    七个对我最好的职业建议
    程序员最艰巨的十大任务
  • 原文地址:https://www.cnblogs.com/luoyubuku/p/3811216.html
Copyright © 2011-2022 走看看