iOS Label设置行间距&判断iphone系统语言

一、Label设置行间距

_textContentLabel.text=self.entity.textContent;

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc ] initWithString:_textContentLabel.text];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];

[paragraphStyle setLineSpacing:5];//调整行间距

[attributedString  addAttribute:NSParagraphStyleAttributeName value: paragraphStyle range:NSMakeRange(0, [_textContentLabel.text length])];

_textContentLabel.attributedText= attributedString;

二、判断系统语言

NSUserDefaults *default1 = [NSUserDefaults standardUserDefaults];

NSArray *languages = [default1 objectForKey:@"AppleLanguages"];

NSString *preferredLang = [languages objectAtIndex:0];

NSLog(@"当前系统语言:%@",preferredLang);

/*

en:英文  

zh-Hans:简体中文

 zh-Hant:繁体中文

   ja:日本

.........

*/

if([preferredLang isEqualToString:@"zh-Hans-CN"]) {

      return@"肩膀";

}else{

     return [@"Shoulder" lowercaseString];

}

你可能感兴趣的:(iOS Label设置行间距&判断iphone系统语言)