1
在iOS 6應用程序中,我將UITextView設置爲接受屬性字符串。將文本與豐富的UITextView中的段落與CoreText對齊?
如何更改段落的文本對齊(左 - 右 - 中心對齊)?
下面的代碼:在與最後一行
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;
墜毀: - [__ NSCFType headIndent]:無法識別的選擇發送到實例0x1559b2d0