iOS AlertController的简单封装

2017-08-01  本文已影响17人  也远

import <UIKit/UIKit.h>

@interface LoginViewController : UIViewController

@end

+(UIAlertController *)showWithInfo:(NSString *)title and:(NSString *)message;

import "YDAlert.h"

@implementation YDAlert

+(UIAlertController *)showWithInfo:(NSString *)title and:(NSString *)message{

UIAlertController * alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *actionOk = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];

[alert addAction:actionOk];

[[YDAlert currentViewController] presentViewController:alert animated:NO completion:^{
    
}];

return alert;

}

一句代码调用
[YDAlert showWithInfo:@"账号和密码不能为空" and:@"请输入账号密码"];

上一篇下一篇

猜你喜欢

热点阅读