我想将自定义颜色移动到UIColor的扩展名:
extension UIColor {
static var nonSelectedTabColor: UIColor {
return UIColor(white: 0.682, alpha: 1) // #AEAEAE
}
}
Run Code Online (Sandbox Code Playgroud)
但是在尝试访问它时,它导致了我一个错误:
private static let defaultBorderColor = .nonSelectedTabColor
Run Code Online (Sandbox Code Playgroud)
Reference to member 'nonSelectedTabColor' cannot be resolved without a contextual type。
这是什么问题?我怎样才能解决这个问题?
我有一个带有标签文本“ +”和“-”的圆形按钮。垂直对齐不正确。
我已经在做
button.contentVerticalAlignment = UIControlContentVerticalAlignment.center
Run Code Online (Sandbox Code Playgroud)
请帮助将其与中心对齐(垂直)。