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

답변

4

만들고 대신 NSParagraphStyle를 사용해보십시오로 전송. (대응 적으로 이름이 동일하다는 것을 나타내지 만 특성 이름에도 NSParagraphStyleAttributeName을 사용해야합니다.)

NSParagraphStyle은 6의 iOS에 새로운 기능입니다. 이전 버전을 대상으로하는 개발자에게 제안 할 내용을 모르겠습니다. .

관련 문제