I am using the UIAppearance protocol to set the text alignment of UILabel throughout my app in appDelegate.
[[UILabel appearance] setTextAlignment:NSTextAlignmentNatural];
Natural text alignment is preferred to cover RTL & LTR language support. But there are some case where I need to keep UILabel as center aligned or right aligned only. That class may have mix approach like some Natural alignment supported & some specific alignment so below code wont be applicable.
[[UILabel appearanceWhenContainedIn:[MyClass class], nil]];
I have tried to set explicitly text alignment of particular UILabel instance but it is not getting applied. Anyone have come across such scenarios?
I explicitly changed expected text alignment for UILabel in "viewWillAppear" for any controller & for table view cell,I applied same changes at "awakeFromNib" & it worked fine. I tried to do it in "layoutSubview" method which DID NOT work.
I believe if you are creating any UILabel programmatically then you can set specific textAlignment which will override UIAppearance proxy work. I have not tested this part.
I hope this will be helpful & save someones time.