Ios NSAttributedString未更改UILabel
嗨,我正在尝试缩进项目符号列表中除第一行以外的所有行。为了做到这一点,我使用了一个带有NSParagraphStyle属性的字符串。但是,它根本不会更改标签。有什么帮助吗Ios NSAttributedString未更改UILabel,ios,objective-c,Ios,Objective C,嗨,我正在尝试缩进项目符号列表中除第一行以外的所有行。为了做到这一点,我使用了一个带有NSParagraphStyle属性的字符串。但是,它根本不会更改标签。有什么帮助吗 NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; style.HeadIndent = 50; NSDictionary *styles=[NSDictionary dictionaryWithObject:style forKe
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.HeadIndent = 50;
NSDictionary *styles=[NSDictionary dictionaryWithObject:style forKey:NSParagraphStyleAttributeName] ;
NSAttributedString* attributedText= [[ NSAttributedString alloc]initWithString:tipsString attributes:styles];
[coachingTips setAttributedText:attributedText];
指导技巧是最重要的标签
谢谢
Josh您必须从属性字符串中获取字符串值。 试试下面这句话
NSDictionary *styles=[NSDictionary dictionaryWithObject:style forKey:NSParagraphStyleAttributeName] ;
NSAttributedString* attributedText= [[ NSAttributedString alloc]initWithString:tipsString attributes:styles];
[coachingTips setAttributedText:[attributedText string];
什么是coachingTips?什么是TipString?除了大写字母属性外,您的代码没有发现任何明显的问题,可能是标签设置有问题-您是否尝试更改其他属性?例如,将前景色改为红色-很容易注意到,尝试更改常规文本,看看这是否会影响主线中的标签?因为你的代码看起来不错。