ios – UIControlState.Normal不可用

ios – UIControlState.Normal不可用,第1张

概述以前对于UIButton实例,您可以传入setTitle或set Image的UIControlState.Normal.正常现在不再可用了,应该用什么呢? let btn = UIButton(frame: CGRect(x: 0, y: 0, width: 20, height: 20))btn.setTitle("title", for: .Normal) // does not comp 以前对于UIbutton实例,您可以传入setTitle或set Image的UIControlState.normal.正常现在不再可用了,应该用什么呢?
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不可用所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1097344.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存