属性テキストをラベルに設定しようとしています。属性は、色だけでなくフォントも機能しているようです。
私が直面している唯一の問題は、行の折り返しです。UILabel のサイズは (200,300) で、numberofLines=0 です。したがって、これで行を折り返す必要がありますが、そうではありません。
NSMutableString *title=[[NSMutableString alloc] init];
NSRange range1;
NSRange range2;
NSRange range3;
NSString *str1=@"ABCD EFGHI klm";
[title appendString:str1];
range1=NSMakeRange(0, str1.length);
NSString *str2=@"PQRSSSS ";
[title appendString:str2];
range2=NSMakeRange(range1.length, str2.length);
NSString *str3=@"1235 2347 989034 023490234 90";
[title appendString:str3];
range3=NSMakeRange(range2.location+range2.length, str3.length);
NSMutableAttributedString *attributeText=[[NSMutableAttributedString alloc] initWithString:title];
[attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color1,NSForegroundColorAttributeName,[self getStlylishItalicFont:13.0] ,NSFontAttributeName,nil] range:range1];
[attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color2,NSForegroundColorAttributeName,[self getStylishFont:13.0] ,NSFontAttributeName,nil] range:range2];
[attributeText setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:color3,NSForegroundColorAttributeName,[self getStylishBoldFont:13.0] ,NSFontAttributeName,nil] range:range3];
self.myTextLabel.attributedText=attributeText;
高さが300なのにUILabelはこのように表示されます。
ABCD EFGHI klm PQRSSSS 1235 234 ...