@property (nonatomic,strong) UIView * submitView; //创建自定义提示框 - (void)viewDidLoad { [super viewDidLoad]; _submitView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Main_Width, Main_height)]; _submitView.hidden = YES; UIWindow *window = [[UIApplication sharedApplication].windows lastObject]; // 添加到窗口 [window addSubview:_submitView]; [self createSubmitView]; } -(void)createSubmitView{ _submitView.hidden = YES;; _submitView.backgroundColor = RGBACOLOR(0, 0, 0, 0.7); _submitView.layer.cornerRadius = 5; timer= [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(pushVC) userInfo:nil repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; submitTime = 5; UIView * view = [[UIView alloc]init]; view.backgroundColor = WhiteColor; [_submitView addSubview:view]; [view mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(_submitView.mas_centerX); make.size.mas_equalTo(CGSizeMake(231*kWidth, 115*kHeight)); make.centerY.mas_equalTo(_submitView.mas_centerY); }]; UILabel * labelSumit = [com createUIlabel:@"发车信息发布成功" andFont:FontOfSize15 andColor:YellowColor]; [view addSubview:labelSumit]; [labelSumit mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(view.mas_centerX); make.top.mas_equalTo(view.mas_top).with.offset(37*kHeight); }]; UIView * line = [[UIView alloc]init]; line.backgroundColor = GrayColor; [view addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(view.mas_centerX); make.top.mas_equalTo(view.mas_top).with.offset(77*kHeight); make.size.mas_equalTo(CGSizeMake(231*kWidth, 0.5)); }]; UIButton * btn1 = [self createBtn:@"继续发布"]; btn1.layer.borderWidth = 0; [btn1 setTitleColor:littleBlackColor forState:UIControlStateNormal]; btn1.tag = 66; [btn1 addTarget:self action:@selector(pressSubmitBtn:) forControlEvents:UIControlEventTouchUpInside]; [view addSubview:btn1]; [btn1 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(line.mas_top); make.size.mas_equalTo(CGSizeMake(231/2*kWidth, 38*kHeight)); make.left.mas_equalTo(view.mas_left); }]; UIButton * btn2 = [self createBtn:@"查看报价(5s)"]; btn2.layer.borderWidth = 0; [btn2 setTitleColor:WhiteColor forState:UIControlStateNormal]; btn2.tag = 67; btn2.backgroundColor = YellowColor; [btn2 addTarget:self action:@selector(pressSubmitBtn:) forControlEvents:UIControlEventTouchUpInside]; [view addSubview:btn2]; [btn2 mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(line.mas_top); make.size.mas_equalTo(CGSizeMake(231/2*kWidth, 38*kHeight)); make.right.mas_equalTo(view.mas_right); }]; } //点击按钮 取消提示背景图的隐藏状态 -(void)pressShipBtn{ _submitView.hidden = NO; UIButton * btn = (UIButton*)[_submitView viewWithTag:67]; NSString * string = [NSString stringWithFormat:@"查看报价(5s)"]; [btn setTitle:string forState:UIControlStateNormal]; }
转载于:https://www.cnblogs.com/sayimba/p/5694088.html