//
//RYTCustomAlertViewController.h
//wojiubuxinle
//
//Created by timmy on 16/10/9.
//Copyright © 2016年 timmy. All rights reserved.
//
#import
typedefvoid(^ACTIONBLOCK)(NSString*msg);
@interfaceRYTCustomAlertViewController :UIAlertController
+ (void)showAlertWithController:(UIViewController*)controller title:(NSString*)title msg:(NSString*)msg;
+ (void)showAlertWithController:(UIViewController*)controller title:(NSString*)title msg:(NSString*)msg style:(UIAlertControllerStyle)style actionFir:(NSString*)actionFir actionSec:(NSString*)actionSec actionThi:(NSString*)actionThi actionFor:(NSString*)actionFor act:(ACTIONBLOCK)act;
+ (void)alertWithController:(UIViewController*)controller seconds:(NSInteger)seconds title:(NSString*)title msg:(NSString*)msg;
@end
//
//RYTCustomAlertViewController.m
//wojiubuxinle
//
//Created by timmy on 16/10/9.
//Copyright © 2016年 timmy. All rights reserved.
//
#import"RYTCustomAlertViewController.h"
#define SCREEN_WIDTHCGRectGetWidth(self.view.frame)
#define SCREEN_HEIGHTCGRectGetHeight(self.view.frame)
@interfaceRYTCustomAlertViewController()
@end
@implementationRYTCustomAlertViewController
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
+ (void)showAlertWithController:(UIViewController*)controller title:(NSString*)title msg:(NSString*)msg {
UIAlertController*alert = [UIAlertControlleralertControllerWithTitle:titlemessage:msgpreferredStyle:UIAlertControllerStyleAlert];
UIAlertAction*action = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleCancelhandler:nil];
[alertaddAction:action];
[controllershowDetailViewController:alertsender:nil];
}
+ (void)showAlertWithController:(UIViewController*)controller title:(NSString*)title msg:(NSString*)msg style:(UIAlertControllerStyle)style actionFir:(NSString*)actionFir actionSec:(NSString*)actionSec actionThi:(NSString*)actionThi actionFor:(NSString*)actionFor act:(ACTIONBLOCK)act {
UIAlertController*alert = [UIAlertControlleralertControllerWithTitle:titlemessage:msgpreferredStyle:style];
if(actionFir) {
UIAlertAction*action = [UIAlertActionactionWithTitle:actionFirstyle:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {
act(actionFir);
}];
[alertaddAction:action];
}
if(actionSec) {
UIAlertAction*action = [UIAlertActionactionWithTitle:actionSecstyle:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {
act(actionSec);
}];
[alertaddAction:action];
}
if(actionThi) {
UIAlertAction*action = [UIAlertActionactionWithTitle:actionThistyle:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {
act(actionThi);
}];
[alertaddAction:action];
}
if(actionFor) {
UIAlertAction*action = [UIAlertActionactionWithTitle:actionForstyle:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {
act(actionFor);
}];
[alertaddAction:action];
}
UIAlertAction*cancleAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
[alertaddAction:cancleAction];
[controllershowDetailViewController:alertsender:nil];
}
+ (void)alertWithController:(UIViewController*)controller seconds:(NSInteger)seconds title:(NSString*)title msg:(NSString*)msg {
UIAlertController*alert = [UIAlertControlleralertControllerWithTitle:titlemessage:msgpreferredStyle:UIAlertControllerStyleAlert];
[controllershowDetailViewController:alertsender:nil];
NSTimer*timer = [NSTimertimerWithTimeInterval:secondsrepeats:NOblock:^(NSTimer*_Nonnulltimer) {
[alertdismissViewControllerAnimated:YEScompletion:nil];
}];
[[NSRunLoopcurrentRunLoop]addTimer:timerforMode:NSRunLoopCommonModes];
}
//NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"heihei"];
//[hogan addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:50] range:NSMakeRange(0, [[hogan string] length])];
//[alert setValue:hogan forKey:@"attributedTitle"];
@end