遍历控件中的label然后修改某些属性

- (void)willPresentAlertView:(UIAlertView *)alertView {
    // 遍历 UIAlertView 所包含的所有控件
    for (UIView *tempView in alertView.subviews) {
 
        if ([tempView isKindOfClass:[UILabel class]]) {
            // 当该控件为一个 UILabel 时
            UILabel *tempLabel = (UILabel *) tempView;
 
            if ([tempLabel.text isEqualToString:alertView.message]) {
                // 调整对齐方式
                tempLabel.textAlignment = UITextAlignmentLeft;
                // 调整字体大小
                [tempLabel setFont:[UIFont systemFontOfSize:15.0]];
            }
        }
    }
}

 

posted @ 2016-01-28 17:52  Show撑腰  阅读(336)  评论(0编辑  收藏  举报