iOS 7中是否有办法完全删除UISegmentedControl
的外框?所选片段的色调颜色应该只有一个矩形。
答案 0 :(得分:3)
首先,创建三个图像并将它们添加到您的图像资源中。
然后添加此代码:
UIImage *backgroundImage = [UIImage imageNamed:@"Blank"];
UIImage *highlightedImage = [UIImage imageNamed:@"Highlight"];
UIImage *selectedImage = [UIImage imageNamed:@"Select"];
UIImage *dividerImage = [[UIImage alloc] init];
[segmentedControl setBackgroundImage:backgroundImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[segmentedControl setBackgroundImage:highlightedImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
[segmentedControl setBackgroundImage:selectedImage forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[segmentedControl setDividerImage:dividerImage forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];