注 : 文章不断更新,转载文章请加上作者
// 设置按钮的文字 title : 需要设置的文字 state : 该文字显示的状态
- (void)setTitle:(NSString *)title forState:(UIControlState)state;
// 设置按钮的文字颜色 color : 设置颜色 state : 该文字颜色显示的状态
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state;
// 设置按钮内部的小图片 state : 该图片显示的状态
- (void)setImage:(UIImage *)image forState:(UIControlState)state;
// 获取按钮上传入的状态的文本 state : 需要获取文本的状态
- (NSString *)titleForState:(UIControlState)state;
// 设置按钮的背景图片 image: 图片 state 该图片显示的状态
- (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state
// 获取按钮内部的小图片
- (UIImage *)imageForState:(UIControlState)state;
//获取按钮内部的背景图片
- (UIImage *)backgroundImageForState:(UIControlState)state;
//获取按钮的文字颜色
- (UIColor *)titleColorForState:(UIControlState)state;
// 按钮中,包括了一个 UILabel 和一个 UIImageView 的子控件
// 所以设置按钮的文字字体,就获取UILabel,去设置Font属性
// @property(nonatomic,readonly,retain) UILabel *titleLabel
// @property(nonatomic,readonly,retain) UIImageView *imageView
UIButton *btnTest = [[UIButton alloc] init];
btnTest.titleLabel.font = [UIFont systemFontOfSize:13];
UIButton有很多状态,它提供了一些便捷属性, 可以直接获取当前状态下得文字, 文字颜色 , 图片等.
@property (nonatomic, readonly, retain) NSString *currenTitle; // 获取文字
@property (nonatomic, readonly, retain) UIColor *currenTitleColor; // 获取文字颜色
@property (nonatomic, readonly, retain) UIImage *currenImage// 获取按钮内部小图片
@property (nonatomic, readonly, retain) UIImage *currenBackGroundImagel; // 获取按钮背景图片
分享到:
相关推荐
UIButton-XibLinesText-源码.rar
UIButton-Bootstrap, 带有 Bootstrap 3.0样式的UIButton 正在查找用于 macOS的平面 NSButtons? 查看 FlatButton uibutton引导程序简单的UIButton类别,可以添加漂亮和平坦的Bootstrap 3.0按钮样式。无子类,无图像...
总结了Swift语言下的UIButton的常用方式,以及RxSwift+MVVM模式下UIButton的使用。
应用场景:向服务器提交数据时(发表动态,上传个人信息....) 优点:防止发表同一样帖子,并且减少服务器的负担.
UIButton-XibLinesText 自动转换UIButton在Xib设置Title时输入的换行符 Import pod 'UIButton-XibLinesText', '~> 1.0.1' Usage 若只设置了UIControlStateNormal的Title或其它State的Title与UIControlStateNormal...
UIButton-Block UIButton的一个Category,使用block处理UIControlEvent事件,如常用的TouchUpInside等 使用方法 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, ...
将方法 setBackgroundColor:forState: 添加到 UIButton 的 Objective-c 类别 UIButton+背景色.h @interface UIButton(BackgroundColor) - (void)setBackgroundColor:(UIColor *)color forState:(UIControlState)...
来源:github/UIButton-BootstrLicence:MIT平台:iOS设备:iPhone / iPad作者:Oskar Groth 无需任何图片,纯代码实现(Quartz Core)具有扁平化、Bootstrap风格的按钮。
UIButton + BackgroundColor UIButton的类别或扩展名,用于将纯背景色设置为背景图像。 安装 可可豆 将此添加到您的Podfile pod 'UIButton+BackgroundColor' 用法 导入<UIButton> ,然后可以使用以下命令为您的...
项目中经常遇到要增大button点击面积的场景,用swift的runtime实现了一个,直接给button的enlarge属性赋值就可以GitHub地址:https://github.com/Yamyee/UIButton-TouchArea
最新代码请移步github: https://github.com/spWang/UIButton-State 如果在使用过程中发现问题,请联系我,wsp810@163.com,如果觉得好用please give a star, 谢谢! 用法如: //setBackgroundColor 1. [button ...
适用于 iOS 的 UIButton 指示器Objective-C 中的一个简单类别,允许您在按下按钮时将活动指示器视图添加到按钮以代替按钮文本。例子 // Show Indicator[_myCustomButton showIndicator ];// Hide Indicator[_...
UIButton使用方法汇总
UIButton是一个标准的UIControl控件 一、创建 两种方法: 1. 常规的 initWithFrame ... UIButton 的一个类方法(也可以说是静态方法)buttonWithType UIButton *btn2 = [UIButton buttonWit
UIButton+Badge,通过运行时的方式对UIButton拓展了标签展示功能 .
Swift编程-UI控件-UIButton(一)视频教程
iphone中的基础控件UIButton, 适合初学者,主要学习UIButton的常用属性设置、方法调用、点击事件等
UIButton 的图文混排,就一个API 还可以在xib里面实现
uibutton的一些基本使用,简单的属性,再加一些封装
UIButton中,默认title在右,image在左。然而很多情况下需要不同的布局,比如左右调换,上下布局。这边利用UIEdgeTitle和UIEdgeImage很好的解决了这种场景