UI控件之--UIButton
2015-10-27 17:19
441 查看
UIButton是UIControl子类,这个类提供了方法来设置标题,图像,按钮等外观属性。通过使用set方法,你可以指定一个不同的外观为每个按钮状态。
// typedef enum {
// UIButtonTypeCustom = 0, 自定义风格
// UIButtonTypeRoundedRect, 圆角矩形
// UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
// UIButtonTypeInfoLight, 亮色感叹号
// UIButtonTypeInfoDark, 暗色感叹号
// UIButtonTypeContactAdd, 十字加号按钮
// } UIButtonType;
// contentEdgeInsets : 切掉按钮内部的内容
// imageEdgeInsets : 切掉按钮内部UIImageView的内容
// titleEdgeInsets : 切掉按钮内部UILabel的内容
shareButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
- (void)setTitle:(NSString *)title forState:(UIControlState)state //设置标题
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state //设置标题颜色
- (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state //设置标题阴影颜色
- (void)setImage:(UIImage *)image forState:(UIControlState)state; //设置图片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state //设置背景图片
- (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)state // 设置标题 ,标题被设定为单行,,
@property(nonatomic,readonly,retain) UILabel *titleLabel // 直接设置titleLabel属性不显示,原因是titleLabel的frame默认是0,hidden=yes;
@property(nonatomic,readonly,retain) UIImageView *imageView
// typedef enum {
// UIButtonTypeCustom = 0, 自定义风格
// UIButtonTypeRoundedRect, 圆角矩形
// UIButtonTypeDetailDisclosure, 蓝色小箭头按钮,主要做详细说明用
// UIButtonTypeInfoLight, 亮色感叹号
// UIButtonTypeInfoDark, 暗色感叹号
// UIButtonTypeContactAdd, 十字加号按钮
// } UIButtonType;
+ (id)buttonWithType:(UIButtonType)buttonType;
// contentEdgeInsets : 切掉按钮内部的内容
// imageEdgeInsets : 切掉按钮内部UIImageView的内容
// titleEdgeInsets : 切掉按钮内部UILabel的内容
shareButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
UIEdgeInsets contentEdgeInsets; // default is UIEdgeInsetsZero UIEdgeInsets titleEdgeInsets; // default is UIEdgeInsetsZero BOOL reversesTitleShadowWhenHighlighted; // default is NO. if YES, shadow reverses to shift between engrave and emboss appearance UIEdgeInsets imageEdgeInsets; // default is UIEdgeInsetsZero BOOL adjustsImageWhenHighlighted; // default is YES. 默认情况下,当按钮高亮的情况下,图像的颜色会被画深一点,如果这下面的这个属性设置为no,那么可以去掉这个功能 BOOL adjustsImageWhenDisabled; // default is YES. 默认情况下,当按钮禁用的时候,图像会被画得深一点,设置NO可以取消设置 BOOL showsTouchWhenHighlighted; // default is NO. 设置为yes的状态下,按钮按下会发光 UIColor *tintColor; // The tintColor is inherited through the superview hierarchy. See UIView for more information. UIButtonType buttonType;
- (void)setTitle:(NSString *)title forState:(UIControlState)state //设置标题
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state //设置标题颜色
- (void)setTitleShadowColor:(UIColor *)color forState:(UIControlState)state //设置标题阴影颜色
- (void)setImage:(UIImage *)image forState:(UIControlState)state; //设置图片
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state //设置背景图片
- (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)state // 设置标题 ,标题被设定为单行,,
@property(nonatomic,readonly,retain) UILabel *titleLabel // 直接设置titleLabel属性不显示,原因是titleLabel的frame默认是0,hidden=yes;
@property(nonatomic,readonly,retain) UIImageView *imageView
相关文章推荐
- uibutton实现左文字右图片
- java之String,StringBuffer,StringBuilder,
- UIScrollView的妙用---textfield编辑不被键盘遮盖(方便简单好实现@.@)
- Codeforces Round #327 (Div. 1) B题: Chip 'n Dale Rescue Rangers [数学题]
- iOS开发UI篇—Quartz2D使用(绘图路径)
- 【adb】adb root报错“adbd cannot run as root in production builds”
- AndroidUI的组成部分GridView
- iOS开发UI篇—Quartz2D简单使用(三)
- DuiVision开发教程(15)-DUI文本控制基础类
- 【NGUI】监听按钮除OnClick外其他事件的方法,附简易改编的UIButton类
- 斯坦福大学公开课 iOS应用开发教程学习笔记(第七课)UIToolbar、iPad 和iPhone的通用程序
- Uiautomator 快速调试
- deque双端队列&&UVa210 Concurrency Simulator(并行程序模拟)的理解与解析
- Uicc之ICCFileHandler(转)
- iOS开发UI篇—Quartz2D使用(图片剪切)
- Carrier frequency 和 EARFCN的关系
- 032.NSValue NSNumber 包装类
- MQTT学习笔记-让Mosquitto支持Websocket
- 虚幻4 build.cs文件里面的每个字符串List的意义
- 浅谈NGUI的NGUITools类