let btn = UIbutton(frame: CGRect(x: 0,y: 0,wIDth: 20,height: 20))btn.setTitle("Title",for: .normal) // does not compile
(这是一个规范的Q& A对,以防止与这个UIbutton和UIControl有关的重复问题的洪水与iOS 10和Swift 3的变化)
解决方法 Swift 3更新:看来Xcode 8 / Swift 3带来了UIControlState.normal:
public struct UIControlState : OptionSet { public init(rawValue: UInt) public static var normal: UIControlState { get } 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}
UIControlState.normal已重命名为UIControlState.normal并从iOS SDK中删除.对于“正常”选项,使用空数组来构造一个空选项集.
let btn = UIbutton(frame: CGRect(x: 0,height: 20))// Does not workbtn.setTitle("Title",for: .normal) // 'normal' has been renamed to 'normal'btn.setTitle("Title",for: .normal) // 'normal' is unavailable: use [] to construct an empty option set// Worksbtn.setTitle("Title",for: [])总结
以上是内存溢出为你收集整理的ios – UIControlState.Normal不可用全部内容,希望文章能够帮你解决ios – UIControlState.Normal不可用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)