Label Alignment in iOS 6 - UITextAlignment deprecated

前端 未结 11 804
再見小時候
再見小時候 2020-12-12 10:59

Seems like UITextAlignmentCenter is deprecated in iOS 6.

I still use it and works well, but it gives a warning.

How can I fix this?

<         


        
11条回答
  •  一整个雨季
    2020-12-12 11:28

    For Swift 5+ use:

    yourLabel.textAlignment = .center
    

    where You can set:

    public enum NSTextAlignment : Int {
        case left = 0 // Visually left aligned
        case center = 1 // Visually centered
        case right = 2 // Visually right aligned
        case justified = 3 // Fully-justified. The last line in a paragraph is natural-aligned.
        case natural = 4 // Indicates the default alignment for script 
    }
    

提交回复
热议问题