企业信息

    北京沃赢科技有限公司

  • 12
  • 公司认证: 营业执照已认证
  • 企业性质:
    成立时间:
  • 公司地址: 北京市 海淀区 海淀街道 北京市海淀区银海大厦
  • 姓名: 刘老师
  • 认证: 手机未认证 身份证未认证 微信未绑定

    IOS基础学习UIButton使用详解

  • 所属行业:商务服务 教育培训 管理培训
  • 发布日期:2015-08-07
  • 阅读量:197
  • 价格:面议
  • 产品规格:不限
  • 产品数量:10000.00 件
  • 包装说明:不限
  • 发货地址:北京海淀海淀  
  • 关键词:在线教育,我赢职场

    IOS基础学习UIButton使用详解详细内容

    IOS基础学习UIButton使用详解
    UIButton按钮是IOS开发中较常用的控件,作为IOS基础学习教程知识 ,初学者需要了解其基本定义和常用设置,以便在开发在熟练运用。
    
    **、UIButton的定义
    
    UIButton *button=[[UIButton buttonWithType:(UIButtonType);
    
    能够定义的button类型有以下6种,
    typedef enum {
    UIButtonTypeCustom = 0, 自定义风格
    UIButtonTypeRoundedRect, 圆角矩形 
    UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
    UIButtonTypeInfoLight, 亮色感叹号
    UIButtonTypeInfoDark, 暗色感叹号
    UIButtonTypeContactAdd, 十字加号按钮
    } UIButtonType;
    
    第二、设置frame
    
    button1.frame = CGRectMake(20, 20, 280, 40);
    [button setFrame:CGRectMake(20,20,50,50)];
    
    第三、button背景色
    
    button1.backgroundColor = [UIColor clearColor];
    [button setBackgroundColor:[UIColor blueColor]];
    
    第四、state状态
    
    forState: 这个参数的作用是定义按钮的文字或图片在何种状态下才会显现
    
    enum {
    UIControlStateNormal = 0, 常规状态显现 
    UIControlStateHighlighted = 1 << 0, 高亮状态显现 
    UIControlStateDisabled = 1 << 1, 禁用的状态才会显现
    UIControlStateSelected = 1 << 2, 选中状态 
    UIControlStateApplication = 0x00FF0000, 当应用程序标志时 
    
    UIControlStateReserved = 0xFF000000 为内部框架预留,可以不管
    };
    
    
    @property(nonatomic,getter=isEnabled)BOOL enabled;                                 // default is YES. if NO, ignores touch events and subclasses may draw differently
    
    @property(nonatomic,getter=isSelected)BOOL selected;                               // default is NO may be used by some subclasses or by application
    
    @property(nonatomic,getter=isHighlighted)BOOL highlighted;                          
    
    *五 、设置button填充图片和背景图片
    
        [buttonsetImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
        [buttonsetBackgroundImage:[UIImageimageNamed:@"checkmarkControllerIcon"]forState:UIControlStateNormal];
    
    第六、设置button标题和标题颜色
    
    [button1 setTitle:@"点击" forState:UIControlStateNormal];
    
    [buttonsetTitleColor:[UIColorredColor]forState:UIControlStateNormal];
    
    第七、设置按钮按下会发光
    
    button.showsTouchWhenHighlighted=NO;
    
    第八、添加或删除事件处理
    
    [button1 addTarget:self action:@selector(butClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [btn removeTarget:nil action:nil forControlEvents:UIControlEventTouchUpInside];
    
    第九、 设置按钮内部图片间距和标题间距
    
    UIEdgeInsets insets; // 设置按钮内部图片间距
    insets.top = insets.bottom = insets.right = insets.left = 10;
    bt.contentEdgeInsets = insets;
    bt.titleEdgeInsets = insets; // 标题间距
    学习链接/ios/?tg=5009295340
    学习交流群:317140762
    
    

    http://jiexiaotan.cn.b2b168.com
    欢迎来到北京沃赢科技有限公司网站, 具体地址是北京市海淀区海淀街道北京市海淀区银海大厦,联系人是刘老师。 主要经营iOS开发、互联网架构师、安卓、Oracle、SAP、RedHat等。 单位注册资金未知。 我们公司主要服务有:教育教学软件等,我们愿以优质的服务和诚意、为您提供精良的产品和专业枝术,共创美好未来!