UIControlState.Normal is Unavailable

后端 未结 4 497
广开言路
广开言路 2020-12-06 05:56

Previously for UIButton instances, you were able to pass in UIControlState.Normal for setTitle or setImage. .Norma

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 06:27

    The .Normal is removed(iOS 10 DP1), you can use the [] or UIControlState(rawValue: UInt(0)) to replace the .Normal, if you don't want to change codes all around(in case apple add it again or you don't like the []), you can just add once this code

    extension UIControlState {
        public static var Normal: UIControlState { return [] }
    }
    

    or

    extension UIControlState {
        public static var Normal: UIControlState { return UIControlState(rawValue: UInt(0)) }
    }
    

    then all the .Normal work like before.

提交回复
热议问题