12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #import "KSCloudPremissionAlertView.h"
- #import <KSToolsLibrary/UIView+Animation.h>
- typedef NS_ENUM(NSInteger, PREMISSION_ACTION) {
- PREMISSION_ACTION_CANCLE = 1001,
- PREMISSION_ACTION_SURE = 1002,
- };
- @interface KSCloudPremissionAlertView ()
- @property (weak, nonatomic) IBOutlet UILabel *tipsMessage;
- @property (nonatomic, copy) CloudAlertButtonCallback cancel;
- @property (nonatomic, copy) CloudAlertButtonCallback confirm;
- @end
- @implementation KSCloudPremissionAlertView
- + (void)configDescMessage:(NSString *)descMsg cancel:(CloudAlertButtonCallback)cancel confirm:(CloudAlertButtonCallback)confirm {
-
- KSCloudPremissionAlertView *alertView = [[[NSBundle mainBundle] loadNibNamed:@"KSCloudPremissionAlertView" owner:self options:nil] firstObject];
- NSString *content = [NSString stringWithFormat:@"请%@访问权限", descMsg];
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:4];
- paragraphStyle.lineBreakMode = NSLineBreakByTruncatingTail;
-
- NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:content attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0f weight:UIFontWeightSemibold],NSForegroundColorAttributeName:HexRGB(0x080808)}];
- [attrs addAttributes:@{NSForegroundColorAttributeName:HexRGB(0xFE445C)} range:[content rangeOfString:descMsg]];
- alertView.tipsMessage.attributedText = attrs;
- alertView.cancel = cancel;
- alertView.confirm = confirm;
- [alertView showAlert];
- }
- - (void)showAlert {
- _isShow = YES;
- UIView *displayView = [NSObject getKeyWindow];
- [displayView addSubview:self];
- [self mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.bottom.mas_equalTo(displayView);
- }];
- [displayView bringSubviewToFront:self];
- [self setPopAnimation];
- }
- - (void)dismissAlertView {
- _isShow = NO;
- [self removeFromSuperview];
- }
- - (IBAction)buttonAction:(UIButton *)sender {
- if (sender.tag == PREMISSION_ACTION_CANCLE) {
- self.cancel();
- }else {
- self.confirm();
- }
- [self dismissAlertView];
- }
- @end
|