在UISegmentedControl的控件中,有一个设置默认颜色的
、
// The tintColor is inherited through the superview hierarchy. See UIView for more information.
@property(null_resettable,nonatomic,strong) UIColor *tintColor;
使用方式如下:
[_segmentedControl setTintColor:[UIColor whiteColor]];
- 设置选中时的背景色
[_segmentedControl setBackgroundImage:[UIImage imageNamed:@"selectImg"]
forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
- 设置为选中时的背景色
[_segmentedControl setBackgroundImage:[UIImage imageNamed:@"unSelectImg"]
forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
- 设置选中时字体颜色
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:RGBA(.94, .31, .18),UITextAttributeTextColor,nil];
[_segmentedControl setTitleTextAttributes:dic forState:UIControlStateSelected];
- 设置默认字体颜色
NSDictionary *dics = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil];
[_segmentedControl setTitleTextAttributes:dics forState:UIControlStateNormal];
本文介绍了如何通过UISegmentedControl的属性设置来定制其外观样式,包括改变选中状态的颜色、背景图片以及字体颜色等。

5300

被折叠的 条评论
为什么被折叠?



