Reputation: 11201
I have an UIAlert builder and i would like to add an image between the title and the button. This is my code:
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];
But the image is shown on top of the UIAlertView.
With @yunas solution:
Could be the image is too big?
Resizing the image:
how can I get it inside the UIAlert?
Upvotes: 0
Views: 76
Reputation: 4163
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];
Upvotes: 1
Reputation: 300
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];
Upvotes: 2