自定义UIAlertView

You can change accessoryView to any own customContentView in a standard alert view in iOS7

[alertView setValue:customContentView forKey:@"accessoryView"];

Note that you must call this before [alertView show].

Simplest illustrating example:

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"TEST" message:@"subview" delegate:nil cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
v.backgroundColor = [UIColor yellowColor];
[av setValue:v forKey:@"accessoryView"];
[av show];

enter image description here

Real tableView as the subview of UIAlertView example:

enter image description here

原文地址:https://www.cnblogs.com/worldtraveler/p/4778401.html