iOS技术集iOS Developer

iOS 自动消失提示框的实现

2017-05-11  本文已影响250人  Swift社区

在app制作过程中,需要使用到提示框自动消失的功能,下面写出一种我常使用的方法:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"提示信息" preferredStyle:UIAlertControllerStyleAlert];
 [self presentViewController:alert animated:YES completion:nil];
//控制提示框显示的时间为2秒
 [self performSelector:@selector(dismiss:) withObject:alert afterDelay:2.0];

实现dismiss:方法

- (void)dismiss:(UIAlertController *)alert{
    [alert dismissViewControllerAnimated:YES completion:nil];
}

希望可以帮助大家
如果哪里有什么不对或者不足的地方,还望读者多多提意见或建议
iOS技术交流群:668562416

上一篇 下一篇

猜你喜欢

热点阅读