RPAlertView 1.4

RPAlertView 1.4

Maintained by TimeMachine Yong.



  • By
  • dengfeng520

RPAlertView

  • iOS 9+

  • license MIT

  • Xcode 10+

AlertDemo1 AlertDemo2 AlertDemo3 AlertDemo4 AlertDemo5 AlertDemo6

Requirements

RPAlertView works on iOS 9+ to build.

Adding RPAlertView to your project

CocoaPods is the recommended way to add RPAlertView to your project.

1、Add a pod entry for RPAlertView to your project Podfile

pod 'RPAlertView'

or

pod 'RPAlertView', :git => 'https://github.com/dengfeng520/RPAlertView'

2、Install the pod by running

pod install

Usage

#import "RPAlertViewController+Animation.h"

OnlyOneBtnMode

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];

CancelAndOKMode

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];