// 1.去掉整个segment颜色,现在整个segment都看不见
self.segment.tintColor = [UIColor clearColor];
// //设置文字属性其,把两个button的文字显示出来
NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName: [UIColor whiteColor]};
[ self.segment setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];
NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:14],NSForegroundColorAttributeName: [UIColor lightTextColor]};
[self.segment setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];

本文介绍如何通过Objective-C自定义iOS中UISegmentedControl的样式,包括如何去除背景颜色并自定义选中与未选中状态的文字属性,如字体大小及颜色。
3192

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



