UIButton的一些设置
2015-07-21 20:17
429 查看
UIButton实在是太搞笑了
1.设置title对齐,第一想到了
button.titleLabel.textAlignment
但是这是没用的,应该用
button.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
注意后半部分不是NSTextAlignmentLeft
2.设置字体颜色,想到了
button.titleLabel.textColor
依然是没用的,应该用
[button setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
3.设置字体,想到了
mainButton.titleLabel.font
这是有用的,终于走了回常规路
但是不能直接用setFont
4.再就是设置title,肯定不能用
mainButton.titleLabel.text
而要用
[mainButton setTitle:titleforState:UIControlStateNormal];
5.button目标target
[button addTarget: action: forControlEvents: ];
另外,target有一个可以暴露的设置
@property(nonatomic, copy) void (^buttonTappedHandler)();
-(IBAction)buttonTapped:(id)sender{
if(self.buttonTappedHandler) self.buttonTappedHandler();
}
继续发掘吧
1.设置title对齐,第一想到了
button.titleLabel.textAlignment
但是这是没用的,应该用
button.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
注意后半部分不是NSTextAlignmentLeft
2.设置字体颜色,想到了
button.titleLabel.textColor
依然是没用的,应该用
[button setTitleColor:[UIColorblackColor] forState:UIControlStateNormal];
3.设置字体,想到了
mainButton.titleLabel.font
这是有用的,终于走了回常规路
但是不能直接用setFont
4.再就是设置title,肯定不能用
mainButton.titleLabel.text
而要用
[mainButton setTitle:titleforState:UIControlStateNormal];
5.button目标target
[button addTarget: action: forControlEvents: ];
另外,target有一个可以暴露的设置
@property(nonatomic, copy) void (^buttonTappedHandler)();
-(IBAction)buttonTapped:(id)sender{
if(self.buttonTappedHandler) self.buttonTappedHandler();
}
继续发掘吧
相关文章推荐
- 2015 Multi-University Training Contest 1 Hdu 5297 Y sequence
- hdu5288(2015多校1)OO’s Sequence
- iOS开发-UITableViewCell(UICollectionViewItem)需要两个手指点击或者长按才可以选中,解决办法
- 多校第一场 1001 hdu 5288 OO’s Sequence(枚举)
- HDU 5288 OO’s Sequence 区间个数
- 2015 Multi-University Training Contest 1 OO’s Sequence
- 多校7.21A——维护技巧——OO’s Sequence
- UITabBarItem初始化详解及UIImage渲染模式
- UILabel 垂直居中问题
- iOS UIView 快速修改 frame,避免累赘的书写方式
- hdu 5288OO’s Sequence
- Failed to instantiate the default view controller for UIMainStoryboardFile 'Main1' - perhaps the des
- uva 10746 Crime Wave - The Sequel (最小费最大流)
- MiniGUI鼠标热插拔支持
- 【瞎搞】HDU 5288 OO’s Sequence
- Rescue-优先队列
- 进入UI_UiView;frame和bound以及视图之间层级关系
- PAT (Advanced Level) 1017. Queueing at Bank (25) 银行排队等待时间
- UIKit框架-11.UITableViewCell概述
- UIKit框架-10.UITableView概述