我的颜色都按照我想要的方式设置:
// Scope bar appearance
[[UISegmentedControl appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor blueColor]];
[[UISegmentedControl appearanceWhenContainedIn: [UISearchBar class], nil] setBackgroundColor:[UIColor whiteColor]];
但是我仍然会看到白色而不是圆润。
见图:
我该如何解决这个问题?感谢。
答案 0 :(得分:0)
请试试这个:
segmentContrl.layer.borderColor = <Set_Your_Color>;
segmentContrl.layer.cornerRadius = 0.5; // You might have to adjust this
segmentContrl.layer.borderWidth = 1.5f; // You might have to adjust this
答案 1 :(得分:0)
在你的AppDelegate中,在顶部添加此代码
@interface UISegmentedControl (Appearance)
- (void)setCornerRadius:(CGFloat)cornerRadius UI_APPEARANCE_SELECTOR;
@end
@implementation UISegmentedControl (Appearance)
- (void)setCornerRadius:(CGFloat)cornerRadius {
self.layer.cornerRadius = cornerRadius;
}
@end
然后您可以在didFinishLaunchingWithOptions
中添加此代码[[UISegmentedControl appearanceWhenContainedIn: [UISearchBar class], nil] setCornerRadius:5];
答案 2 :(得分:0)
设置cornerRadius后尝试调用以下代码。
segmentContrl.clipsToBounds = true