Ios TextAlign在UIAlertView中不工作?
我想在UIAlertView中对齐我的消息文本,这是我的代码,但当我运行此代码时,文本显示与以前一样,在for循环之后没有任何更改。我还想增加我的文字?我现在正在使用这个代码Ios TextAlign在UIAlertView中不工作?,ios,objective-c,iphone,uialertview,text-alignment,Ios,Objective C,Iphone,Uialertview,Text Alignment,我想在UIAlertView中对齐我的消息文本,这是我的代码,但当我运行此代码时,文本显示与以前一样,在for循环之后没有任何更改。我还想增加我的文字?我现在正在使用这个代码 UIAlertView *alret = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]] message:[NSString st
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];
试试这个
for (UIView *view in alert.subviews) {
if([[view class] isSubclassOfClass:[UILabel class]]) {
((UILabel*)view).textAlignment = NSTextAlignmentLeft;
}
}
希望能有帮助