【发布时间】:2020-07-28 08:30:47
【问题描述】:
在 iOS 中,当 UIViewController 呈现一个弹出框时,其视图的 tintColor 将变为黑白颜色(这样,按钮看起来弹出框可见时不可点击)。当弹出框消失时,颜色会变回来。
UIView 有一个子类来保存徽章计数。该视图层的颜色应该与视图的 tintColor 具有相同的颜色。
如何在其父视图中同步子层的tintColor?
// draw orange background layer with border
override func draw(_ rect: CGRect) {
layer.cornerRadius = rect.height / 2
layer.borderColor = UIColor.orange.cgColor
layer.borderWidth = 2
layer.backgroundColor = UIColor.white.cgColor
layer.masksToBounds = true
}
默认值:
提交:
【问题讨论】: