Home > DeveloperSection > Forums > TextAlign not working in UIAlertView?
Jayne Spooner
Jayne Spooner

Total Post:21

Posted on    August-07-2015 5:05 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 524  View(s)
Rate this:

I want to Aligned my message text in UIAlertView and here is my code but when i running this code the text appear as before and nothing change after for loop. i also want to increase my text? I am using this code Align text in a UIAlertView that has a scrollbar right now.

UIAlertView *alret = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat: @"%@",

[title objectAtIndex:indexPath.row]] message:

[NSString stringWithFormat:@"%@",

[description objectAtIndex:indexPath.row]] delegate:nil

cancelButtonTitle: @"OK" otherButtonTitles:nil];

for(id subview in alret.subviews) {

    if([subview isKindOfClass:[UITextView class]]) {

        [(UITextView *)subview setTextAlignment:NSTextAlignmentJustified];


} [alret show];


Tarun Kumar

Total Post:210

Posted on    August-07-2015 8:38 AM

Try this

for (UIView *view in alert.subviews) {

    if([[view class] isSubclassOfClass:[UILabel class]]) {

        ((UILabel*)view).textAlignment = NSTextAlignmentLeft;



Hope it helps.

Don't want to miss updates? Please click the below button!

Follow MindStick