iOS成长之button

一.button的几种类型

+ (id)buttonWithType:(UIButtonType)buttonType; 指定button的类型

类型值:(六种)

typedef NS_ENUM(NSInteger, UIButtonType) {

    UIButtonTypeCustom = 0,                                    // 自定义风格,点击没有点击效果

    UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0),      // 系统自带风格按钮

    UIButtonTypeDetailDisclosure,       //带有感叹号图片,有效果,做详细说明使用

    UIButtonTypeInfoLight,      //亮色感叹号

    UIButtonTypeInfoDark,      //暗色感叹号

    UIButtonTypeContactAdd,     //十字加号按钮

    UIButtonTypeRoundedRect   //与系统自带风格一样

};

 

二.button的一些属性

1. forState: 这个参数的作用是定义按钮的文字或图片在何种状态下才会显现*/
    //以下是几种状态
    enum {
        UIControlStateNormal       = 0,         常规状态显现             
        UIControlStateHighlighted  = 1 << 0,    高亮状态显现   
        UIControlStateDisabled     = 1 << 1,    禁用的状态才会显现
        UIControlStateSelected     = 1 << 2,    选中状态             
        UIControlStateApplication  = 0x00FF0000, 当应用程序标志时           
        UIControlStateReserved     = 0xFF000000  为内部框架预留,可以不管他            
    };

 

 

2.  btn.layer.cornerRadius = 3;    //设置按钮的圆角大小

3.  

    [btn.titleLabel setFont:[UIFont fontNamesForFamilyName:@"字体暂时不会"]];   //修改button的字体样式

    [btn.titleLabel setFont:[UIFont systemFontOfSize:10]];      //修改button的字体大小

 

posted @ 2015-08-17 18:27  风灵子偌  阅读(129)  评论(0编辑  收藏  举报