0

I want to make some part of my text in UITextView to be right justified.

I use NSAttributedString and use the code below for justifying the text:

NSMutableParagraphStyle * justifiedStyle = [[NSMutableParagraphStyle alloc] init];
justifiedStyle.alignment= NSTextAlignmentJustified;


NSDictionary *firstAttributes = @{
                                  NSForegroundColorAttributeName: [UIColor blueColor],
                                     NSParagraphStyleAttributeName: justifiedStyle
                                };

[myString appendAttributedString:
[[NSMutableAttributedString alloc] initWithString:myNewString attributes:firstAttributes]
     ];

but it is not working and cause an app crash.

I saw some related topics like:

Justified text with UITextView and NSMutableAttributedString

and others as well. Someone said that if I use firstLineHeadIndent it should work. Others suggest using 'addTab' but none of them are working for me. Does anyone work with this in iOS7 ?

Edit Regarding to crash log:

Actually it goes to main.m file and select the return line but green color and at the End of green line writes:

Thread 1: EXC_BAD_ACCESS (code=2, Address= 0x8)

No comments apprearing on the output box.

Community
  • 1
  • 1
Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115

0 Answers0