ios6

What are good alternatives to UITextAlignmentCenter in iOS 6?


UITextAlignmentCenter seems to be deprecated in iOS 6. What are my alternatives?


Solution

  • For IOS 6 you should use NSTextAlignmentCenter instead of UITextAlignmentCenter:

    button.titleLabel.textAlignment = NSTextAlignmentCenter;
    

    Source

    And if you want backward compatibiliy to IOS 5 also you can do this,

    #ifdef __IPHONE_6_0
    # define ALIGN_CENTER NSTextAlignmentCenter
    #else
    # define ALIGN_CENTER UITextAlignmentCenter
    #endif