一,效果图。
二,代码。
class="cnblogs_code_copy" style="font-size: 18px">- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:nil message:@"此信息3秒后消失" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
[alert show];
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:3.0];
}
- (void)dismissAlert:(UIAlertView*)alert {
if ( alert.visible ) {
[alert dismissWithClickedButtonIndex:alert.cancelButtonIndex animated:YES];
}
}