您的位置:首页 > 产品设计 > UI/UE

自定义UIAlertView背景

2013-09-16 15:37 411 查看
系统自带的UIAlertView背景有点丑,我们可以自定义,写一个UIAlertView的类别. 核心代码如下:

- (void)changeBackground{

    for (UIView *view in [self subviews]) {
        if ([view isKindOfClass:[UIImageView class]]) {
            UIImage *image = [UIImage imageNamed:@"5-1.png"];
            UIImageView *back = (UIImageView *)view;
            back.image = image;
            break;
        }
    }
}

调用方式: 

   UIAlertView *alert = [[UIAlertView
alloc]initWithTitle:@"a"
message:nil
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil,
nil];
    
    [alert show];
    [alert changeBackground];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: