123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //
- // ASDefualtAlertV.m
- // Asteria
- //
- // Created by iOS on 2023/6/17.
- //
- #import "ASDefualtAlertV.h"
- #import "ASHomeAlertWindow.h"
- @interface ASDefualtAlertV ()
- @property (nonatomic, strong) UIView *bgV;
- @property (nonatomic, strong) UIButton *closeBt;
- @property (nonatomic, strong) UILabel *msgLb;
- @end
- @implementation ASDefualtAlertV
- - (void)setMsg:(NSString *)msg {
- self.msgLb.text = msg;
- }
- - (void)setViewStyle:(ASAlertWidthStyle)style {
- [self mas_updateConstraints:^(MASConstraintMaker *make) {
- switch (style) {
- case ASAlertWidthStyleLittle:
- make.width.equalTo(@180);
- break;
- case ASAlertWidthStyleMiddle:
- make.width.equalTo(@230);
- default:
- make.width.equalTo(@(KScreenWidth-60));
- break;
- }
- }];
- }
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self loadSubV];
- }
- return self;
- }
- - (void)loadSubV {
- [self addSubview:self.bgV];
- [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self);
- make.top.leading.greaterThanOrEqualTo(self).offset(10);
- make.width.equalTo(@180);
- }];
- [self.bgV addSubview:self.msgLb];
- [self.bgV addSubview:self.closeBt];
- [self.msgLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.bgV).offset(-30);
- make.trailing.equalTo(self.bgV).offset(-20);
- make.top.equalTo(self.closeBt.mas_bottom).offset(10);
- make.leading.equalTo(self.bgV).offset(20);
- }];
- [self.closeBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgV).offset(10);
- make.trailing.equalTo(self.bgV).offset(-10);
- make.width.height.equalTo(@36);
- }];
- }
- - (UILabel *)msgLb {
- if (!_msgLb) {
- UILabel *lb = [UILabel baseLb];
- lb.textAlignment = NSTextAlignmentCenter;
- lb.font = [UIFont fontWithName:Rob_Regular size:14];
- lb.numberOfLines = 0;
- lb.qmui_lineHeight = 24;
- lb.textColor = Col_000;
- _msgLb = lb;
- }
- return _msgLb;
- }
- - (UIButton *)closeBt {
- if (!_closeBt) {
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- [btn setImage:[UIImage imageNamed:@"productLsit_filter_close"] forState:UIControlStateNormal];
- [btn addTarget:self action:@selector(closeBTAction) forControlEvents:UIControlEventTouchUpInside];
- _closeBt = btn;
- }
- return _closeBt;
- }
- - (UIView *)bgV {
- if (!_bgV) {
- UIView *v = [UIView baseV];
- v.backgroundColor = Col_FFF;
- v.layer.cornerRadius = 8;
- v.layer.masksToBounds = true;
- _bgV = v;
- }
- return _bgV;
- }
- - (void)closeBTAction {
- [ASHomeAlertWindow clearWindow];
- if (self.closeAction) {
- self.closeAction();
- }
- }
- @end
|