RPAlertView
-
iOS 9+
-
许可证 MIT
-
Xcode 10+
要求
RPAlertView 支持在 iOS 9+ 上构建。
将 RPAlertView 添加到您的项目中
CocoaPods 是将 RPAlertView 添加到您项目的推荐方式。
1、在您的项目 Podfile 中添加对 RPAlertView 的 pod 条目
pod 'RPAlertView'
或者
pod 'RPAlertView', :git => 'https://github.com/dengfeng520/RPAlertView'
2、运行以下命令来安装 pod:
pod install
使用方法
#import "RPAlertViewController+Animation.h"
只有一个按钮的模式
RPAlertViewController *alertView = [[RPAlertViewController alloc] initWithMode:showRoot];
[alertView configAlertOnlyOneBtn:@"title" body:@"body" btnTitle:@"OK"];
alertView.modalPresentationStyle = UIModalPresentationCustom;
alertView.oneBtnBlock = ^{
};
[self presentViewController:alertView animated:true completion:nil];
取消和确定模式
RPAlertViewController *alertView = [[RPAlertViewController alloc] initWithMode:showRoot];
[alertView configMixedAlert:@"title" body:@"body" leftBtnTitle:@"cancel" rightBtnTitle:@"OK"];
alertView.modalPresentationStyle = UIModalPresentationCustom;
alertView.leftBtnBlock = ^{
};
alertView.rightBtnBlock = ^{
};
[self presentViewController:alertView animated:true completion:nil];
NSMutableAttributedString
NSString *fristChar = @"Since you are reported by multiple users, your account is forbidden from matching and chatting for ";
NSString *secondChar = @"7 day";
NSString *thridChar = @"\n\n\t Please chat and behaviour properly, or your account will be banned forever.";
NSString *string = [NSString stringWithFormat:@"%@%@.%@",fristChar,secondChar,thridChar];
NSMutableAttributedString *bodyText = [[NSMutableAttributedString alloc] initWithString:string];
[bodyText addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:248/255.0 green:92/255.0 blue:92/255.0 alpha:1] range:[string rangeOfString:secondChar]];
[bodyText addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"PingFangSC-Semibold" size:16] range:NSMakeRange(0, bodyText.length)];
RPAlertViewController *alertView = [[RPAlertViewController alloc] initWithMode:showRoot];
[alertView configAttributedStringAlertOnlyOneBtnTitle:@"title" body:bodyText btnText:@"OK"];
alertView.modalPresentationStyle = UIModalPresentationCustom;
alertView.oneBtnBlock = ^{
};
[self presentViewController:alertView animated:true completion:nil];