UISegmentedControl自定义背景颜色和字体颜色
2016-11-21 15:13
274 查看
在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];
相关文章推荐
- Android 自定义 spinner (背景、字体颜色)
- 设置UITableView Section的背景颜色和字体颜色-自定义Section
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Mac终端(Terminal)自定义颜色,字体,背景
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- C#控制台自定义背景颜色,字体颜色大全
- Android自定义Button字体颜色和背景颜色
- AnctionBar透明背景,自定义字体颜色大小,自定义overflow按钮
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android---Tablayout自定义Tab的背景和字体的颜色变化
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- Android 自定义 spinner (背景、字体颜色)
- VS MONO Android开发控件悬浮显示提醒 自定义背景颜色、字体、数字颜色、摆放位置
- AS 自定义主题字体颜色和背景
- (转)Android 自定义 spinner (背景、字体颜色)
- 吐司工具类ToastUtil--集系统吐司,可设置背景颜色和字体颜色吐司,以及自定义布局吐司