圆角在 iOS 12 及更低版本上运行良好,但在 iOS 13 上已损坏。我创建了一个自定义 Segment 控件类。
代码:
class SegmentedControl: UISegmentedControl {
override func layoutSubviews() {
super.layoutSubviews()
layer.cornerRadius = self.bounds.size.height / 2.0
layer.borderColor = UIColor(red: 170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0, alpha: 1.0).cgColor
layer.borderWidth = 1.0
layer.masksToBounds = true
clipsToBounds = true
}
}
Run Code Online (Sandbox Code Playgroud)
我已经阅读了这篇文章 -如何在 iOS 13 的 UISegmentedControl 中更改段的颜色? 但我找不到任何解决方案。