UIButton的基础知识

摘自:欧阳大神的UI教学视频

UIButton 的类型

1、UIButtonTypeRoundedRect 圆角按钮

2、UIButtonTypeDetailDisclosure 详情按钮

3、UIButtonTypeContactAdd 加号按钮

4、UIButtonTypeInfoDark 白色信息按钮

5、UIButtonTypeInfoLight 灰色信息按钮

6、 UIButtonTypeCustom 自定义按钮

 

UIButton的常用属性

1、frame 坐标

2、tag 标签

3、adjustsImageWhenHighlighted 高亮状态下按钮是否变暗

4、adjustsImageWhenDisabled 禁用状态下按钮是否变暗

5、showsTouchWhenHighlighted 按钮高亮状态下是否发光

 

UIButton的常用方法

1、- (void)setTitle:(NSString *)title forState:(UIControlState)state;

2、- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;

3、- (void)setTitleShadowColor:(UIColor *)color forState:forState:(UIControlState)state;

4、- (void)setImage:(UIImage *)image forState:(UIControlState)state;

5、- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state;

6、- (void)setTintColor:(UIColor *)color;

 

UIButton 的事件

1、- (void)addTarget:(id)target action:(SEL)action forControlEvent:(UIControlEvents)controlEvents

2、- (void)removeTarget:(id)target action:(SEL)action forControlEvent:(UIControlEvents)controlEvents

 

UIButton修改图片和标题位置

1、默认情况下从工厂方法中生成的按钮,图片在左边,标题在右边

2、通过继承UIButton重写方法来设置自己想要的位置

3、按钮类型需为UIButtonTypeCustom

 

posted @ 2015-05-17 14:07  H_F  阅读(198)  评论(0编辑  收藏  举报