Ios 是否将rich UITextView中的段落与CoreText对齐?
在iOS 6应用程序中,我将UITextView设置为接受属性字符串 如何更改段落的文本左对齐-右对齐-居中对齐 以下代码:Ios 是否将rich UITextView中的段落与CoreText对齐?,ios,uitextview,core-text,nsattributedstring,text-alignment,Ios,Uitextview,Core Text,Nsattributedstring,Text Alignment,在iOS 6应用程序中,我将UITextView设置为接受属性字符串 如何更改段落的文本左对齐-右对齐-居中对齐 以下代码: NSMutableAttributedString *mutableAttributeString = [textView.attributedText mutableCopy]; CTTextAlignment alignment = kCTCenterTextAlignment; CTParagraphStyleSetting settings[] = {kCTP
NSMutableAttributedString *mutableAttributeString = [textView.attributedText mutableCopy];
CTTextAlignment alignment = kCTCenterTextAlignment;
CTParagraphStyleSetting settings[] = {kCTParagraphStyleSpecifierAlignment, sizeof(alignment), &alignment};
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, sizeof(settings) / sizeof(settings[0]));
CFAttributedStringSetAttribute((CFMutableAttributedStringRef)mutableAttributeString, CFRangeMake(0, CFAttributedStringGetLength((CFMutableAttributedStringRef)mutableAttributeString)), kCTParagraphStyleAttributeName, paragraphStyle);
CFRelease(paragraphStyle);
textView.attributedText = mutableAttributeString;
在最后一行崩溃,原因是:
-[\uu NSCFType headIndent]:发送到实例0x1559b2d0的无法识别的选择器请尝试创建并使用NSParagraphStyle。相应地,您还应该为属性名称使用NSParagraphStyleAttributeName,尽管行为表明名称相同
NSParagraphStyle是iOS 6中的新样式。我不知道应该为针对旧版本的开发人员提供什么建议。尝试创建并使用NSParagraphStyle。相应地,您还应该为属性名称使用NSParagraphStyleAttributeName,尽管行为表明名称相同 NSParagraphStyle是iOS 6中的新样式。我不知道应该为针对旧版本的开发人员提供什么建议