问题
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?
回答1:
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];
}
}
来源:https://stackoverflow.com/questions/13113653/align-text-in-a-uialertview-that-has-a-scrollbar