I am stuck to one point i want to develop a app that support LTR and RTL both but i don't want to create two .xib for LTR and RTL.
So can any one provide me any method avalable fot LTR to RTL using same xib.
thank you in advance.
I am stuck to one point i want to develop a app that support LTR and RTL both but i don't want to create two .xib for LTR and RTL.
So can any one provide me any method avalable fot LTR to RTL using same xib.
thank you in advance.
There is no need to create 2 xib files in order to get LTR and RTL to work.
Basically you need to:
In some cases you may want to force RTL/LTR images using imageFlippedForRightToLeftLayoutDirection():
image = [image imageFlippedForRightToLeftLayoutDirection];
while checking current language using:
BOOL isLeftToRight = [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:[[self view] semanticContentAttribute]] == UISemanticContentAttributeForceLeftToRight;
Remember that each UIView has semanticContentAttribute that can be set to force RTL UISemanticContentAttributeForceRightToLeft. i.e:
[view setSemanticContentAttribute: UISemanticContentAttributeForceRightToLeft];
When using textFields please use the below alignment so each RTL/LTR will work as it should be:
You can do this by changing the semantics
self.anyView.semanticContentAttribute = .forceLeftToRight
OR
self.anyView.semanticContentAttribute = .forceRightToLeft
In objective-c
self.anyView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
Or
self.anyView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
see also this demo : RTLDemo
below are a few of my methods.
first of all, verify if the layout direction (you could create a macro for this)
[UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft
use IBOutlet for NSLayoutConstraint and set constant/priority to shift your UI elements
NSTextAlignmentNatural
for left alignment in LTR and for RTL will take care the system. Else you have to set them by yourself the text alignmentThese are important for me, but there are more. Just be creative