目前在做中东项目,除了需要做语言国际化适配之外,发现手机操作习惯也不一致:大多数国家从左到右的习惯,而中东则从右到左。
先判断系统语言是否阿拉伯世界;之后调用系统设置;具体而言:
1.
BOOL isArabicKay =NO;
NSArray *languages = [NSLocale preferredLanguages];
NSString *currentLanguage = [languages objectAtIndex:0];
isArabicKay = [currentLanguage rangeOfString:@"ar"].location != NSNotFound;
2.
+ (void)initRTL:(BOOL)isRTL {
if(isRTL) {
[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
}else {
[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}
}