Edg*_*gel 3 uicontrolstate swift swift3 ios10
我在Xcode 8上用iOS10将我的应用更新为Swift 3,我收到错误:
Btn.setTitle('str', forState: .Normal)
Run Code Online (Sandbox Code Playgroud)
.Normal不再是UIControlState的枚举类型.我应该将哪种类型的UIControlState用于此状态?
Apple枚举现在定义为
public struct UIControlState : OptionSet {
public init(rawValue: UInt)
public static var highlighted: UIControlState { get } // used when UIControl isHighlighted is set
public static var disabled: UIControlState { get }
public static var selected: UIControlState { get } // flag usable by app (see below)
@available(iOS 9.0, *)
public static var focused: UIControlState { get } // Applicable only when the screen supports focus
public static var application: UIControlState { get } // additional flags available for application use
public static var reserved: UIControlState { get } // flags reserved for internal framework use
}
Run Code Online (Sandbox Code Playgroud)
像任何其他选项集一样:
button.setTitle("", for: [])
Run Code Online (Sandbox Code Playgroud)
where []代表.normal(.normalis 的值0).
请注意,我们可以在一个调用中使用多个状态:
button.setTitle("", for: [.selected, .disabled])
Run Code Online (Sandbox Code Playgroud)
这就是为什么UIControlState已经变成了一个选项集.
| 归档时间: |
|
| 查看次数: |
5166 次 |
| 最近记录: |