123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- //
- // AlertMyCartDeleteV.m
- // westkissMob
- //
- // Created by 王猛 on 2022/10/19.
- //
- #import "AlertMyCartDeleteV.h"
- @interface AlertMyCartDeleteV (){
- UIView * _maskView;
- }
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIButton *closeBtn;
- @property (nonatomic, strong) QMUILabel *titleLab;
- @property (nonatomic, strong) UIButton *yesBtn;
- @property (nonatomic, strong) UIButton *noBtn;
- @end
- @implementation AlertMyCartDeleteV
- - (instancetype)initWithPaytypeAlertV:(UIImage *)payImg closeBtnImg:(UIImage *)closeImg{
- self = [super init];
- if (self) {
- [self paytype_addSubViewPayImg:payImg closeBtnImg:closeImg];
- }
- return self;
- }
- - (void)dealTap:(UITapGestureRecognizer *)tap{
- [self alertv_remove];
- }
- -(void)paytype_addSubViewPayImg:(UIImage *)payImg closeBtnImg:(UIImage *)closeImg{
- self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
- _maskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
- _maskView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.8];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dealTap:)];
- [_maskView addGestureRecognizer:tap];
- [self addSubview:_maskView];
-
- UIImageView *payImgV = [[UIImageView alloc]initWithImage:payImg];
- payImgV.frame = CGRectMake(0, 0, payImg.size.width, payImg.size.height);
- payImgV.center = self.center;
- payImgV.userInteractionEnabled = YES;
- [self addSubview:payImgV];
-
- UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- closeBtn.frame = CGRectMake((payImgV.mj_w-40)/2, 10, 40, 40);
- [closeBtn setImage:closeImg forState:UIControlStateNormal];
- [closeBtn addTarget:self action:@selector(handle_closeBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
- [payImgV addSubview:closeBtn];
- }
- -(void)handle_closeBtnEvent:(UIButton *)btn{
- [self alertv_remove];
- }
- -(void)alertv_show{
- [[UIApplication sharedApplication].keyWindow addSubview:self];
- }
- -(void)alertv_remove{
- [_maskView removeFromSuperview];
- [self removeFromSuperview];
- }
- - (instancetype)initWithYesBtnAlertVtitle:(NSString *)titile yesTitle:(NSString *)btnTitle;{
- self = [super init];
- if (self) {
- [self tt_setupViews];
- [self alertTitleYesBtn_AddsubViews:titile yesTitle:btnTitle];
-
- }
- return self;
- }
- #pragma mark - **************** 特殊方法 alertTitleYesBtn ****************
- -(void)alertTitleYesBtn_AddsubViews:(NSString *)title yesTitle:(NSString *)btnTitle{
- [self.bgView addSubview:self.titleLab];
- [self.bgView addSubview:self.yesBtn];
- self.titleLab.font = [UIFont fontWithName:Rob_Regular size:14];
- self.titleLab.text = title;
-
- self.yesBtn.backgroundColor = [UIColor colorWithHexString:@"#000000"];
- self.yesBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
- [self.yesBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
- NSAttributedString *btnStr = [[NSAttributedString alloc] initWithString:btnTitle];
- [self.yesBtn setAttributedTitle:btnStr forState:UIControlStateNormal];
- [self.yesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(132);
- make.height.mas_equalTo(35);
- make.centerX.mas_equalTo(0);
- make.bottom.mas_equalTo(-30);
- }];
- [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.closeBtn.mas_bottom).offset(20);
- make.left.mas_equalTo(20);
- make.width.mas_equalTo(KScreenWidth -70-40);
- make.bottom.equalTo(self.yesBtn.mas_top).offset(-20);
- }];
-
- }
- - (instancetype)initWithAlertVtitle:(NSMutableAttributedString *)titile{
- self = [super init];
- if (self) {
- [self tt_setupViews];
- [self alertTitle_AddSubViews:titile];
- }
- return self;
- }
- #pragma mark - **************** 特殊方法 alertTitle_****************
- -(void)alertTitle_AddSubViews:(NSMutableAttributedString *)title{
- [self.bgView addSubview:self.titleLab];
- [self.bgView addSubview:self.yesBtn];
- [self.bgView addSubview:self.noBtn];
- [self alertTitle_titleVFrameWithTitle:title];
- }
- -(void)alertTitle_titleVFrameWithTitle:(NSMutableAttributedString *)title{
- CGSize maxsize = CGSizeMake((KScreenWidth -70-40),MAXFLOAT);
- [title addAttribute:NSFontAttributeName
- value:[UIFont fontWithName:Rob_Bold size:14]
- range:NSMakeRange(0, title.length)];
- CGFloat labelHeight = [title boundingRectWithSize:maxsize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size.height;
- self.titleLab.attributedText = title;
- self.titleLab.textAlignment = NSTextAlignmentCenter;
- [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.closeBtn.mas_bottom).offset(20);
- make.left.mas_equalTo(20);
- make.width.mas_equalTo(KScreenWidth -70-40);
- make.height.mas_equalTo(labelHeight + 40);
- }];
- [self.noBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(120);
- make.height.mas_equalTo(35);
- make.centerX.mas_equalTo(0);
- make.top.equalTo(self.titleLab.mas_bottom).offset(20);
- make.bottom.mas_equalTo(-30);
-
- }];
- [self.yesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.noBtn.mas_left).offset(-15);
- make.top.equalTo(self.titleLab.mas_bottom).offset(20);
- make.height.mas_equalTo(35);
- make.width.mas_equalTo(35);
- }];
- }
- #pragma mark - **************** 公共方法 ****************
- - (void)tt_setupViews{
- self.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
- self.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.3];
- [[UIApplication sharedApplication].keyWindow addSubview:self];
- [self addSubview:self.bgView];
- [self.bgView addSubview:self.closeBtn];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(35);
- make.right.mas_equalTo(-35);
- make.centerY.mas_equalTo(0);
- make.height.mas_equalTo(200);
- }];
-
- [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(20);
- make.width.height.mas_equalTo(40);
- make.centerX.mas_equalTo(0);
- }];
-
- }
- #pragma mark - **************** handle ****************
- -(void)handle_CloseViewEvent:(UIButton *)btn{
- [self removeFromSuperview];
- }
- -(void)handle_yesClickEvent:(UIButton *)btn{
- if (self.ViewtapClose) {
- self.ViewtapClose(1, @"");
- }
- [self removeFromSuperview];
- }
- -(void)handle_noClickEvent:(UIButton *)btn{
- if (self.ViewtapClose) {
- self.ViewtapClose(0, @"");
- }
- [self removeFromSuperview];
- }
- -(UIView *)bgView{
- if(!_bgView){
- _bgView = [[UIView alloc]init];
- _bgView.backgroundColor = [UIColor colorWithHexString:@"#FFDEE2"];
- }
- return _bgView;
- }
- -(UIButton *)closeBtn{
- if(!_closeBtn){
- _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_closeBtn setImage:[UIImage imageNamed:@"base_close_black"] forState:UIControlStateNormal];
- [_closeBtn addTarget:self action:@selector(handle_CloseViewEvent:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _closeBtn;
- }
- -(QMUILabel *)titleLab{
- if(!_titleLab){
- _titleLab = [[QMUILabel alloc]init];
- _titleLab.textAlignment = NSTextAlignmentCenter;
- _titleLab.font = [UIFont fontWithName:Rob_Bold size:14];
- }
- return _titleLab;
- }
- -(UIButton *)yesBtn{
- if(!_yesBtn){
- _yesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _yesBtn.backgroundColor = [UIColor clearColor];
- [_yesBtn setTitle:@"YES" forState:UIControlStateNormal];
- [_yesBtn setTitleColor:Col_000 forState:UIControlStateNormal];
- [_yesBtn addTarget:self action:@selector(handle_yesClickEvent:) forControlEvents:UIControlEventTouchUpInside];
- NSMutableAttributedString *noString = [[NSMutableAttributedString alloc] initWithString:@"YES"];
- [noString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [noString length])];
- [_yesBtn setAttributedTitle:noString forState:UIControlStateNormal];
- _yesBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
- }
- return _yesBtn;
- }
- -(UIButton *)noBtn{
- if(!_noBtn){
- _noBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _noBtn.backgroundColor = Col_000;
- [_noBtn setTitleColor:Col_FFF forState:UIControlStateNormal];
- [_noBtn addTarget:self action:@selector(handle_noClickEvent:) forControlEvents:UIControlEventTouchUpInside];
- NSMutableAttributedString *noString = [[NSMutableAttributedString alloc] initWithString:@"NO"];
- [noString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [noString length])];
- [_noBtn setAttributedTitle:noString forState:UIControlStateNormal];
- _noBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
-
- }
- return _noBtn;
- }
- @end
|