반응형
What are good alternatives to UITextAlignmentCenter in iOS 6?
UITextAlignmentCenter
seems to be deprecated in iOS 6. What are my alternatives?
For IOS 6 you should use NSTextAlignmentCenter
instead of UITextAlignmentCenter
:
button.titleLabel.textAlignment = NSTextAlignmentCenter;
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
#ifdef __IPHONE_6_0
# define ALIGN_CENTER NSTextAlignmentCenter
#else
# define ALIGN_CENTER UITextAlignmentCenter
#endif
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
label.text = @"There is no spoon";
label.textAlignment = ALIGN_CENTER;
[self addSubview:label];
You can do
newLabel.textAlignment = NSTextAlignmentCenter;
instead of
newLabel.textAlignment = UITextAlignmentCenter;
hope it helps.
You should use NSTextAlignmentCenter
instead according to Apple's documentation.
You should also use NSTextAlignmentLeft
and NSTextAlignmentRight
instead of UITextAlignmentLeft
and UITextAlignmentRight
, respectively.
In Swift: NSTextAlignment.Center
ReferenceURL : https://stackoverflow.com/questions/12792999/what-are-good-alternatives-to-uitextalignmentcenter-in-ios-6
반응형
'programing' 카테고리의 다른 글
import win32api error in Python 2.6 (0) | 2021.01.17 |
---|---|
Select all where [first letter starts with B] (0) | 2021.01.17 |
Using RSpec to check if something is an instance of another object (0) | 2021.01.17 |
How to set include path in xcode project (0) | 2021.01.17 |
Spring Bean Scopes (0) | 2021.01.17 |