123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- //
- // RQAlertViewManager.m
- // YJZS
- //
- // Created by 张嵘 on 2022/4/11.
- //
- #import "RQAlertViewManager.h"
- static RQAlertViewManager *manger = nil;
- static dispatch_once_t onceToken;
- @interface RQAlertViewManager ()
- @property (nonatomic, readwrite, strong) UIView *commonHeaderView;
- @end
- @implementation RQAlertViewManager
- #pragma mark - SystemMethod
- + (RQAlertViewManager *)sharedManager {
- dispatch_once(&onceToken, ^{
- manger = [[self alloc] init];
- });
- return manger;
- }
- - (instancetype)init {
- self = [super init];
- if (self) {
- }
- return self;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- #pragma mark - PublicMethods
- /**
- 弹出alertController,并且有两个个action按钮,分别有处理事件
-
- @param alertType 弹窗类型
- @param title title
- @param message Message
- @param confirmTitle 左边按钮的title
- @param cancelTitle 右边按钮的title
- @param confirmAction 左边按钮的点击事件
- */
- - (void)showAlertWithAlertType:(RQAlertType)alertType title:(NSString * _Nullable )title message:(NSString * _Nullable )message confirmTitle:(NSString *)confirmTitle cancelTitle:(NSString * _Nullable )cancelTitle confirmAction:(void (^__nullable)(__kindof QMUIDialogViewController *dialogViewController))confirmAction {
- [self showAlertWithAlertType:alertType title:title message:message confirmTitle:confirmTitle cancelTitle:cancelTitle confirmAction:confirmAction cancelAction:nil];
- }
- /**
- 弹出alertController,并且有两个个action按钮,分别有处理事件
-
- @param alertType 弹窗类型
- @param title title
- @param message Message
- @param confirmTitle 左边按钮的title
- @param cancelTitle 右边按钮的title
- @param confirmAction 左边按钮的点击事件
- @param cancelAction 右按钮的点击事件
- */
- - (void)showAlertWithAlertType:(RQAlertType)alertType title:(NSString * _Nullable )title message:(NSString * _Nullable )message confirmTitle:(NSString *)confirmTitle cancelTitle:(NSString * _Nullable )cancelTitle confirmAction:(void (^__nullable)(__kindof QMUIDialogViewController *dialogViewController))confirmAction cancelAction:(void (^__nullable)(__kindof QMUIDialogViewController *dialogViewController))cancelAction {
-
- QMUIDialogViewController *dialogViewController = [[QMUIDialogViewController alloc] init];
- dialogViewController.headerSeparatorColor = nil;
- dialogViewController.headerViewBackgroundColor = UIColor.whiteColor;
-
- CGFloat textHeight = [message heightForFont:RQRegularFont_16 width:RQ_SCREEN_WIDTH - 80.f - 32.f] + 16 > RQ_SCREEN_HEIGHT / 2.f? RQ_SCREEN_HEIGHT / 2.f : [message heightForFont:RQRegularFont_16 width:RQ_SCREEN_WIDTH - 80.f - 32.f] + 16;
- dialogViewController.headerViewHeight = (alertType == RQAlertType_Default)? (24.f + 22.f + 16.f + textHeight + 16.f) : 180.f;
-
- NSString *headerImageName = @"";
- CGSize headerImageSize = CGSizeZero;
- switch (alertType) {
- case RQAlertType_Rignt:
- headerImageName = @"正确";
- headerImageSize = CGSizeMake((RQ_SCREEN_WIDTH - 80.f) / 3.f, ((RQ_SCREEN_WIDTH - 80.f) / 3.f) / (96.f / 71.f));
- break;
- case RQAlertType_Warn:
- headerImageName = @"提示";
- headerImageSize = CGSizeMake((RQ_SCREEN_WIDTH - 80.f) / 3.f, ((RQ_SCREEN_WIDTH - 80.f) / 3.f) / (96.f / 64.f));
- break;
- case RQAlertType_Error:
- headerImageName = @"错误";
- headerImageSize = CGSizeMake(RQ_SCREEN_WIDTH - 80.f, (RQ_SCREEN_WIDTH - 80.f) / (277.f / 117.f));
- break;
-
- default:
- break;
- }
-
- UIImageView *headerIconImageView = [[UIImageView alloc] initWithImage:RQImageNamed(headerImageName)];
- headerIconImageView.contentMode = UIViewContentModeScaleAspectFill;
- if (RQStringIsNotEmpty(headerImageName)) {
- [dialogViewController.headerView addSubview:headerIconImageView];
- [headerIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset((alertType == RQAlertType_Error)? 0 : 40);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(headerImageSize);
- }];
- }
-
-
- QMUILabel *titleLabel = [[QMUILabel alloc] qmui_initWithFont:RQSemiboldFont(20) textColor:[UIColor qmui_colorWithHexString:@"#040B26"]];
- titleLabel.text = title;
- titleLabel.textAlignment = NSTextAlignmentCenter;
- [dialogViewController.headerView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(RQStringIsNotEmpty(headerImageName)? headerIconImageView.mas_bottom : dialogViewController.headerView.mas_top).mas_offset(24);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH - 80.f, 22.f));
- }];
-
- QMUILabel *messageLabel = [[QMUILabel alloc] qmui_initWithFont:RQRegularFont_16 textColor:[UIColor qmui_colorWithHexString:@"#5C6066"]];
- NSMutableAttributedString *mutAttrStr = [[NSMutableAttributedString alloc] initWithString:message];
- if ([message containsString:@"永久删除"]) {
- [mutAttrStr addAttribute:NSForegroundColorAttributeName value:RQ_MAIN_TEXT_COLOR_RED range:[message rangeOfString:@"永久删除"]];
- }
- if ([message containsString:@"VIP用户的VIP权益也将失效"]) {
- [mutAttrStr addAttribute:NSForegroundColorAttributeName value:RQ_MAIN_TEXT_COLOR_RED range:[message rangeOfString:@"VIP用户的VIP权益也将失效"]];
- }
- if (alertType == RQAlertType_SignOut) {
- messageLabel.attributedText = mutAttrStr;
- } else {
- messageLabel.text = message;
- }
-
-
- messageLabel.textAlignment = NSTextAlignmentLeft;
- messageLabel.numberOfLines = 0;
- [dialogViewController.headerView addSubview:messageLabel];
- [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleLabel.mas_bottom).mas_offset(16);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH - 80.f - 32.f, textHeight));
- }];
-
-
- UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 80.f, 36)];
- contentView.backgroundColor = UIColorWhite;
- dialogViewController.contentView = contentView;
-
- dialogViewController.footerSeparatorColor = nil;
- dialogViewController.footerViewBackgroundColor = UIColor.whiteColor;
- dialogViewController.footerViewHeight = 84.f;
- dialogViewController.footerView.hidden = NO;
- CGFloat btnWidth = (RQ_SCREEN_WIDTH - 80.f - (16 * 2) - 16) / 2.f;
-
- QMUIButton *cancleBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
- [cancleBtn setTitle:cancelTitle textColor:[UIColor qmui_colorWithHexString:@"#5C6066"] Font:15 fotState:UIControlStateNormal];
- cancleBtn.layer.borderColor = [UIColor qmui_colorWithHexString:@"#5C6066"].CGColor;
- cancleBtn.layer.borderWidth = 1;
- cancleBtn.layer.cornerRadius = 20;
- cancleBtn.layer.masksToBounds = YES;
- [cancleBtn setBlockForControlEvents:UIControlEventTouchUpInside block:^(id _Nonnull sender) {
- [dialogViewController hide];
- if (cancelAction) {
- cancelAction(dialogViewController);
- }
- }];
- [dialogViewController.footerView addSubview:cancleBtn];
- [cancleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(0);
- make.left.mas_offset(16);
- make.size.mas_equalTo(CGSizeMake(btnWidth, 40.f));
- }];
-
- QMUIButton *confirmBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
- [confirmBtn setTitle:confirmTitle textColor:UIColor.whiteColor Font:15 fotState:UIControlStateNormal];
- [confirmBtn setBackgroundImage:[UIImage qmui_imageWithColor:RQ_MAIN_COLOR size:CGSizeMake(100.f, 40.f) cornerRadius:0] forState:UIControlStateNormal];
- [confirmBtn setBackgroundImage:[UIImage qmui_imageWithColor:[UIColor qmui_colorWithHexString:@"#8A9099"] size:CGSizeMake(100.f, 40.f) cornerRadius:0] forState:UIControlStateDisabled];
- confirmBtn.layer.cornerRadius = 20;
- confirmBtn.layer.masksToBounds = YES;
- [confirmBtn setBlockForControlEvents:UIControlEventTouchUpInside block:^(id _Nonnull sender) {
- [dialogViewController hide];
- if (confirmAction) {
- confirmAction(dialogViewController);
- }
- }];
- [dialogViewController.footerView addSubview:confirmBtn];
- [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(0);
- make.right.mas_offset(-16);
- make.size.mas_equalTo(CGSizeMake(btnWidth, 40.f));
- }];
-
- if (alertType == RQAlertType_SignOut) {
- [confirmBtn setEnabled:!(alertType == RQAlertType_SignOut)];
-
- __block NSInteger customIndex = 11;
- [[[RACSignal interval:1 onScheduler:[RACScheduler mainThreadScheduler]] take:customIndex] subscribeNext:^(id x) {
- customIndex --;
- [confirmBtn setTitleNormal:[NSString stringWithFormat:@"%@(%lds)",confirmTitle,customIndex]];
- [confirmBtn setEnabled:customIndex <= 0];
- if (customIndex <= 0) {
- [confirmBtn setTitleNormal:confirmTitle];
- }
- }];
- }
-
-
- [dialogViewController show];
- }
- /**
- 弹出alertController,并且有三个action按钮
-
- @param confirmOneAction 右边按钮的点击事件
- @param confirmTwoAction 右边按钮的点击事件
- */
- - (void)showAlertWithConfirmOneAction:(void(^)(void))confirmOneAction confirmTwoAction:(void(^)(void))confirmTwoAction {
- NSString *title = @"温馨提示";
- NSString *message = @"请选择培训科目";
- NSString *cancelTitle = @"取消";
- NSString *confirmTitleOne = @"科目二";
- NSString *confirmTitleTwo = @"科目三";
- SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindowWidth:RQ_SCREEN_WIDTH - 80.f];
- CGFloat viewTextWideth = RQ_SCREEN_WIDTH - (20 * 2) - (40 * 2);
- CGFloat textHeight = [message heightForFont:[UIFont systemFontOfSize:16] width:viewTextWideth] + 16 > RQ_SCREEN_HEIGHT / 2.f? RQ_SCREEN_HEIGHT / 2.f : [message heightForFont:[UIFont systemFontOfSize:16] width:viewTextWideth] + 16;
- [alert removeTopCircle];
- alert.tintTopCircle = NO;
- alert.useLargerIcon = NO;
- alert.iconTintColor = RQ_MAIN_COLOR;
- alert.cornerRadius = 10;
-
- NSString *imageName = @"提示";
- CGSize imageSize = imageSize = CGSizeMake((RQ_SCREEN_WIDTH - 80.f) / 3.f, ((RQ_SCREEN_WIDTH - 80.f) / 3.f) / (96.f / 64.f));
- UIImageView *iconImageView = [[UIImageView alloc] qmui_initWithSize:imageSize];
- iconImageView.image = RQImageNamed(imageName);
- iconImageView.contentMode = UIViewContentModeScaleAspectFill;
- [alert addCustomView:iconImageView];
- [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(20);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(imageSize);
- }];
-
-
-
- alert.labelTitle.textColor = RQ_MAIN_TEXT_COLOR_1;
- alert.labelTitle.font = [UIFont boldSystemFontOfSize:20];
-
- [alert.labelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(iconImageView.mas_bottom).mas_offset(20);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(viewTextWideth, 21.f));
- }];
-
- UITextView *messageTextView = [[UITextView alloc] initWithFrame:CGRectMake(20, alert.labelTitle.rq_y + alert.labelTitle.rq_height, viewTextWideth, textHeight)];
- messageTextView.font = RQRegularFont_13;
- messageTextView.editable = NO;
- messageTextView.textColor = RQ_MAIN_TEXT_COLOR_3;
- messageTextView.textAlignment = NSTextAlignmentCenter;
- messageTextView.text = message;
- [alert addCustomView:messageTextView];
-
- [messageTextView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(alert.labelTitle.mas_bottom).mas_offset(18);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(viewTextWideth, textHeight));
- }];
-
- SCLButton *confirmButton = [alert addButton:confirmTitleOne validationBlock:^BOOL{
- return YES;
- } actionBlock:confirmOneAction];
-
- confirmButton.buttonFormatBlock = ^NSDictionary* (void) {
- NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
- buttonConfig[@"cornerRadius"] = @"20.f";
- buttonConfig[@"backgroundColor"] = RQ_MAIN_COLOR;
- buttonConfig[@"textColor"] = RQ_MAIN_TEXT_COLOR_WHITE;
- buttonConfig[@"font"] = [UIFont systemFontOfSize:16];
- return buttonConfig;
- };
-
- [confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(messageTextView.mas_bottom).mas_offset(15);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(viewTextWideth - 16, 40.f));
- }];
-
- SCLButton *confirmButton1 = [alert addButton:confirmTitleTwo validationBlock:^BOOL{
- return YES;
- } actionBlock:confirmTwoAction];
-
- confirmButton1.buttonFormatBlock = ^NSDictionary* (void) {
- NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
- buttonConfig[@"cornerRadius"] = @"20.f";
- buttonConfig[@"backgroundColor"] = RQ_MAIN_COLOR;
- buttonConfig[@"textColor"] = RQ_MAIN_TEXT_COLOR_WHITE;
- buttonConfig[@"font"] = [UIFont systemFontOfSize:16];
- return buttonConfig;
- };
-
- [confirmButton1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(confirmButton.mas_bottom).mas_offset(8);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(viewTextWideth - 16, 40.f));
- }];
-
- SCLButton *cancelButton = [alert addButton:cancelTitle validationBlock:^BOOL{
- return YES;
- } actionBlock:nil];
- cancelButton.buttonFormatBlock = ^NSDictionary* (void) {
- NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
- buttonConfig[@"cornerRadius"] = @"20.f";
- buttonConfig[@"backgroundColor"] = RQ_MAIN_BACKGROUNDCOLOR;
- buttonConfig[@"textColor"] = RQColorFromHexString(@"#D5DDE0");
- buttonConfig[@"borderWidth"] = @1.0f;
- buttonConfig[@"borderColor"] = RQColorFromHexString(@"#D5DDE0");
- buttonConfig[@"font"] = [UIFont systemFontOfSize:16];
- return buttonConfig;
- };
-
- [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(confirmButton1.mas_bottom).mas_offset(8);
- make.centerX.mas_offset(0);
- make.bottom.mas_offset(-20);
- make.size.mas_equalTo(CGSizeMake(viewTextWideth - 16, 40.f));
- }];
-
-
-
- alert.horizontalButtons = YES;
- alert.showAnimationType = SCLAlertViewShowAnimationFadeIn;
- [alert showTitle:title subTitle:nil style:SCLAlertViewStyleCustom closeButtonTitle:nil duration:0.f];
- }
- - (void)showEmailAlertConfirmAction:(void (^__nullable)(__kindof QMUIDialogViewController *dialogViewController, __kindof QMUITextField *textFiled))confirmAction {
- QMUIDialogViewController *dialogViewController = [[QMUIDialogViewController alloc] init];
- dialogViewController.headerSeparatorColor = nil;
- dialogViewController.headerViewBackgroundColor = UIColor.whiteColor;
- NSString *title = @"请输入您的邮箱";
- NSString *message = @"5分钟内将发送到您的邮箱,请注意查收。";
-
- CGFloat textHeight = [message heightForFont:RQRegularFont_16 width:RQ_SCREEN_WIDTH - 80.f - 32.f] + 16 > RQ_SCREEN_HEIGHT / 2.f? RQ_SCREEN_HEIGHT / 2.f : [message heightForFont:RQRegularFont_16 width:RQ_SCREEN_WIDTH - 80.f - 32.f] + 16;
-
- NSString *headerImageName = @"信纸边缘";
- CGSize headerImageSize = CGSizeMake(RQ_SCREEN_WIDTH - 80.f, (RQ_SCREEN_WIDTH - 80.f) / (290.f / 9.f));
-
- dialogViewController.headerViewHeight = headerImageSize.height + 24.f + 22.f + 16.f + textHeight + 16.f ;
-
-
-
- UIImageView *headerIconImageView = [[UIImageView alloc] initWithImage:RQImageNamed(headerImageName)];
- headerIconImageView.contentMode = UIViewContentModeScaleAspectFill;
- if (RQStringIsNotEmpty(headerImageName)) {
- [dialogViewController.headerView addSubview:headerIconImageView];
- [headerIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(0);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(headerImageSize);
- }];
- }
-
- QMUIButton *cancleBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
- [cancleBtn setImage:RQImageNamed(@"close") forState:UIControlStateNormal];
- [cancleBtn setBlockForControlEvents:UIControlEventTouchUpInside block:^(id _Nonnull sender) {
- [dialogViewController hide];
- }];
- [dialogViewController.headerView addSubview:cancleBtn];
- [cancleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(headerIconImageView.mas_bottom).mas_offset(16);
- make.right.mas_offset(-16);
- make.size.mas_equalTo(CGSizeMake(RQ_FIT_HORIZONTAL(16.f), RQ_FIT_HORIZONTAL(16.f)));
- }];
-
-
- QMUILabel *titleLabel = [[QMUILabel alloc] qmui_initWithFont:RQSemiboldFont(20) textColor:[UIColor qmui_colorWithHexString:@"#040B26"]];
- titleLabel.text = title;
- titleLabel.textAlignment = NSTextAlignmentCenter;
- [dialogViewController.headerView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(RQStringIsNotEmpty(headerImageName)? headerIconImageView.mas_bottom : dialogViewController.headerView.mas_top).mas_offset(24);
- make.left.mas_offset(16);
- make.right.mas_equalTo(cancleBtn.mas_left).mas_offset(-8);
- make.height.mas_equalTo(22.f);
- }];
-
- QMUILabel *messageLabel = [[QMUILabel alloc] qmui_initWithFont:RQRegularFont_16 textColor:[UIColor qmui_colorWithHexString:@"#5C6066"]];
- NSMutableAttributedString *mutAttrStr = [[NSMutableAttributedString alloc] initWithString:message];
- if ([message containsString:@"永久删除"]) {
- [mutAttrStr addAttribute:NSForegroundColorAttributeName value:RQ_MAIN_TEXT_COLOR_RED range:[message rangeOfString:@"永久删除"]];
- }
- if ([message containsString:@"VIP用户的VIP权益也将失效"]) {
- [mutAttrStr addAttribute:NSForegroundColorAttributeName value:RQ_MAIN_TEXT_COLOR_RED range:[message rangeOfString:@"VIP用户的VIP权益也将失效"]];
- }
- messageLabel.text = message;
-
-
- messageLabel.textAlignment = NSTextAlignmentCenter;
- messageLabel.numberOfLines = 0;
- [dialogViewController.headerView addSubview:messageLabel];
- [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleLabel.mas_bottom).mas_offset(16);
- make.centerX.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH - 80.f - 32.f, textHeight));
- }];
-
- UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - 80.f, 68)];
- contentView.backgroundColor = UIColorWhite;
- UIView *bgView = [[UIView alloc] init];
- bgView.backgroundColor = RQColorFromHexString(@"#F2F3F5");
- bgView.layer.cornerRadius = 18.f;
- bgView.layer.borderWidth = 1;
- bgView.layer.borderColor = RQColorAlpha(124, 129, 136, 0.16).CGColor;
- bgView.layer.masksToBounds = YES;
- [contentView addSubview:bgView];
- [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.mas_offset(16);
- make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH - 80.f - 32.f, 36));
- }];
- UIImageView *iconImageView = [[UIImageView alloc] initWithImage:RQImageNamed(@"邮箱")];
- [bgView addSubview:iconImageView];
- [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_offset(16);
- make.centerY.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(RQ_FIT_HORIZONTAL(14.4f), RQ_FIT_HORIZONTAL(10.9f)));
- }];
- QMUITextField *textFiled = [[QMUITextField alloc] init];
- textFiled.frame = CGRectMake(CGRectGetMaxX(iconImageView.frame) + 16.f, 0, RQ_SCREEN_WIDTH - 80.f - 32.f - CGRectGetMaxX(iconImageView.frame) - 24.f, 36);
- textFiled.placeholder = @"请输入您的邮箱";
- textFiled.placeholderColor = RQColorFromHexString(@"#BFBFBF");
- textFiled.keyboardType = UIKeyboardTypeEmailAddress;
- textFiled.clearButtonMode = UITextFieldViewModeWhileEditing;
- textFiled.text = RQStringIsNotEmpty(RQ_COMMON_MANAGER.historyEmailStr)? RQ_COMMON_MANAGER.historyEmailStr : @"";
- [bgView addSubview:textFiled];
- [textFiled mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(iconImageView.mas_right).mas_offset(8);
- make.top.bottom.mas_offset(0);
- make.right.mas_offset(-16);
- }];
-
- dialogViewController.contentView = contentView;
-
- dialogViewController.footerSeparatorColor = nil;
- dialogViewController.footerViewBackgroundColor = UIColor.whiteColor;
- dialogViewController.footerViewHeight = 84.f;
- dialogViewController.footerView.hidden = NO;
- CGFloat btnWidth = (RQ_SCREEN_WIDTH - 80.f - (16 * 2) - 16) / 2.f;
-
-
-
- QMUIButton *confirmBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
- [confirmBtn setTitle:@"确认" textColor:UIColor.whiteColor Font:15 fotState:UIControlStateNormal];
- [confirmBtn setBackgroundImage:[UIImage qmui_imageWithColor:RQ_MAIN_COLOR size:CGSizeMake(100.f, 40.f) cornerRadius:0] forState:UIControlStateNormal];
- [confirmBtn setBackgroundImage:[UIImage qmui_imageWithColor:[UIColor qmui_colorWithHexString:@"#8A9099"] size:CGSizeMake(100.f, 40.f) cornerRadius:0] forState:UIControlStateDisabled];
- confirmBtn.layer.cornerRadius = 20;
- confirmBtn.layer.masksToBounds = YES;
- [confirmBtn setBlockForControlEvents:UIControlEventTouchUpInside block:^(id _Nonnull sender) {
- if ([NSString rq_isValidEmail:textFiled.text]) {
- RQ_COMMON_MANAGER.historyEmailStr = textFiled.text;
- [dialogViewController hide];
- if (confirmAction) {
- confirmAction(dialogViewController, textFiled);
- }
- } else {
- [MBProgressHUD rq_showTips:@"请输入正确的邮箱" addedToView:dialogViewController.view];
- }
- }];
- [dialogViewController.footerView addSubview:confirmBtn];
- [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.mas_offset(0);
- make.size.mas_equalTo(CGSizeMake(btnWidth, 40.f));
- }];
-
- [dialogViewController show];
- }
- - (UIView *)commonHeaderView {
- if (!_commonHeaderView) {
- _commonHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH - (40 * 2), 117)];
- }
- return _commonHeaderView;
- }
- @end
|