ios - UISegmentedControl外观无边框锐边

标签 ios objective-c uisegmentedcontrol

我很生气。我花了很多时间,没有合适的结果。

我想重新设计(作为外观)这个

enter image description here

对此

enter image description here

或者用程序化的话......从这个:

+(void)configureSegmentedControls {

   [[UISegmentedControl appearance] setTintColor:[COLOR_PROXY highlightColor]];

   [[UISegmentedControl appearance] setBackgroundColor:[COLOR_PROXY darkBackgroundColor]];

   [[UISegmentedControl appearance] setDividerImage:[UIImage new] forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

   NSDictionary *selectedAttributes = @{NSFontAttributeName:[FONT_PROXY fontNormalOfSizeSmall],
                             NSForegroundColorAttributeName:[UIColor whiteColor]};

   [[UISegmentedControl appearance] setTitleTextAttributes:selectedAttributes
                                               forState:UIControlStateSelected];

   NSDictionary *normalAttributes = @{NSFontAttributeName:[FONT_PROXY fontNormalOfSizeSmall],
               NSForegroundColorAttributeName:[COLOR_PROXY highlightColor]};

   [UISegmentedControl appearance] setTitleTextAttributes:normalAttributes
                                               forState:UIControlStateNormal];

   NSDictionary *disabledAttributes = @{NSFontAttributeName:[FONT_PROXY fontNormalOfSizeSmall],
                                    NSForegroundColorAttributeName:[COLOR_PROXY lightGrayTextColor]};

   [[UISegmentedControl appearance] setTitleTextAttributes:disabledAttributes forState:UIControlStateDisabled];
}

为此:

???

最佳答案

您可以像这样实现这种外观:

self.segmentedControl.layer.cornerRadius = 0;
self.segmentedControl.layer.borderColor = [UIColor whiteColor].CGColor;
self.segmentedControl.layer.borderWidth = 1.5;

[UIColor WhiteColor] 替换为分段控件的 super View 的背景颜色。

关于ios - UISegmentedControl外观无边框锐边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35506329/

相关文章:

ios - UISegmentedController 在按同一段两次后卡住

ios - 导航栏的底线或工具栏的顶线?

iphone - UINavigationController inside UIViewController 位于 UINavigationConroller 内

ios - Swift -'init(cgImage:options:alphaType:)' 已弃用 : Replaced by MTIImage(cgImage:options:isOpaque:)

iphone - NS_ENUM 给出编译器关于前向引用的警告

ios - iOS插件中的malloc错误

objective-c - 拖放创建拖动图像

ios - 分段控件中 TableView 中的 UIStepper

ios - 从iphone应用商店过渡到企业开发

swift - 如何在 Swift 的工具栏顶部居中分段控件?