1

If a UIAlertView contains a certain amount of text, the text display is automatically changed to have scrollbars. I would like this text to be centre-aligned.

Searching around for the solution provides this SO response. However, this does not work on a UIAlertView that contains scrollbars.

How do I align the text in such an alert?

Community
  • 1
  • 1
CaptainProg
  • 5,610
  • 23
  • 71
  • 116

1 Answers1

0

My suggestion would be to not do this. It could break with any iOS update if Apple changes the way that UIAlertView is structured. That being said, you can do this:

for(id subview in alertView.subviews) {
    if([subview isKindOfClass:[UITextView class]]) {
        [(UITextView *)subview setTextAlignment:NSTextAlignmentCenter];
    }
}
Michael Frederick
  • 16,664
  • 3
  • 43
  • 58