0

我有一个 UIAlert 构建器,我想在标题和按钮之间添加一个图像。这是我的代码:

UIAlertView *pull = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"pull_wire", nil)
                                    message:nil
                                    delegate:nil
                                    cancelButtonTitle:NSLocalizedString(@"continue_text", nil)
                                    otherButtonTitles:nil];

UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"cable.png"]];

[pull addSubview:imageView];
[pull show];

但是图像显示在 UIAlertView 的顶部。

使用@yunas 解决方案:

在此处输入图像描述

会不会是图太大了?

调整图像大小:

在此处输入图像描述

如何在 UIAlert 中获取它?

4

2 回答 2

2
UIAlertView *pull = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"pull_wire", nil)
                                message:@"\n\n\n\n\n\n\n\n\n\n\n\n"
                                delegate:nil
                                cancelButtonTitle:NSLocalizedString(@"continue_text", nil)
                                otherButtonTitles:nil];
于 2013-04-08T08:19:40.183 回答
1
UIAlertView *pull = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"pull_wire", nil)
                                    message:nil
                                    delegate:nil
                                    cancelButtonTitle:NSLocalizedString(@"continue_text", nil)
                                    otherButtonTitles:nil];

[pull show];

UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"cable.png"]];
    CGRect frame = imageView.frame;
    frame.origin = CGPointMake(0, 80); // set the origin here
    frame.size = CGSizeMake(90,40);//ANY SIZE that you want, but remember if you want the alertview to be big in size you need to apply transformation on the pull (ALERTVIEW)
[imageView setFrame:frame];
[pull addSubview:imageView];
于 2013-04-08T08:42:10.550 回答