137 lines
4.7 KiB
Objective-C
137 lines
4.7 KiB
Objective-C
//
|
|
// TongYiXieYiAlterView.m
|
|
// ProductApp
|
|
//
|
|
// Created by 工作 on 2024/7/2.
|
|
//
|
|
|
|
#import "TongYiXieYiAlterView.h"
|
|
#import "AppDelegate.h"
|
|
|
|
@interface TongYiXieYiAlterView ()
|
|
|
|
@property (nonatomic , strong) UILabel *lbtitle;
|
|
@property (nonatomic , strong) UILabel *lbinfo;
|
|
|
|
///
|
|
@property (nonatomic , strong) NSString *strtitle;
|
|
@property (nonatomic , strong) NSString *strinfo;
|
|
|
|
///
|
|
@property (nonatomic , strong) TongYiXieYiAlterViewBack backValue;
|
|
|
|
@end
|
|
|
|
@implementation TongYiXieYiAlterView
|
|
|
|
-(id)initWithFrame:(CGRect)frame
|
|
{
|
|
if(self = [super initWithFrame:frame])
|
|
{
|
|
[self setBackgroundColor:RGBACOLOR(0, 0, 0, 0.4)];
|
|
|
|
UIView *viewback = [[UIView alloc] init];
|
|
[viewback setBackgroundColor:[UIColor whiteColor]];
|
|
[self addSubview:viewback];
|
|
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(50);
|
|
make.right.equalTo(self).offset(-50);
|
|
make.center.equalTo(self);
|
|
}];
|
|
[viewback.layer setMasksToBounds:YES];
|
|
[viewback.layer setCornerRadius:20];
|
|
|
|
UILabel *lbtitle = [[UILabel alloc] init];
|
|
[lbtitle setText:@"温馨提示"];
|
|
[lbtitle setTextColor:RGBCOLOR(255, 213, 108)];
|
|
[lbtitle setTextAlignment:NSTextAlignmentLeft];
|
|
[lbtitle setFont:[UIFont fontWithName:@"PangMenZhengDao" size:30]];
|
|
[lbtitle setNumberOfLines:2];
|
|
[viewback addSubview:lbtitle];
|
|
[lbtitle mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(viewback);
|
|
make.top.offset(23);
|
|
}];
|
|
_lbtitle = lbtitle;
|
|
|
|
UILabel *lbinfo = [[UILabel alloc] init];
|
|
[lbinfo setText:@""];
|
|
[lbinfo setTextColor:RGBCOLOR(107, 107, 107)];
|
|
[lbinfo setLineBreakMode:NSLineBreakByWordWrapping];
|
|
[lbinfo setTextAlignment:NSTextAlignmentLeft];
|
|
[lbinfo setFont:[UIFont systemFontOfSize:14]];
|
|
[lbinfo setNumberOfLines:0];
|
|
[viewback addSubview:lbinfo];
|
|
[lbinfo mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(40);
|
|
make.right.equalTo(viewback).offset(-40);
|
|
make.top.equalTo(lbtitle.mas_bottom).offset(20);
|
|
}];
|
|
_lbinfo = lbinfo;
|
|
|
|
|
|
UIButton *btok = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH-210, 40)];
|
|
[btok setTitle:@"我已查看并同意" forState:UIControlStateNormal];
|
|
[btok setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
[btok.titleLabel setFont:[UIFont systemFontOfSize:16]];
|
|
[btok.layer setMasksToBounds:YES];
|
|
[btok.layer setCornerRadius:10];
|
|
[viewback addSubview:btok];
|
|
[btok mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.offset(65);
|
|
make.right.equalTo(viewback).offset(-65);
|
|
make.top.equalTo(lbinfo.mas_bottom).offset(38);
|
|
make.height.offset(40);
|
|
}];
|
|
[btok addTarget:self action:@selector(okAction) forControlEvents:UIControlEventTouchUpInside];
|
|
[btok.layer setMasksToBounds:YES];
|
|
[btok.layer setCornerRadius:6];
|
|
[Tools changedView:btok colors:MainJBColors startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
|
|
|
|
UIButton *btdis = [[UIButton alloc] init];
|
|
[btdis setTitle:@"在考虑一下" forState:UIControlStateNormal];
|
|
[btdis setTitleColor:RGBCOLOR(102, 102, 102) forState:UIControlStateNormal];
|
|
[btdis.titleLabel setFont:[UIFont systemFontOfSize:12]];
|
|
[viewback addSubview:btdis];
|
|
[btdis mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(btok);
|
|
make.top.equalTo(btok.mas_bottom);
|
|
make.height.offset(40);
|
|
}];
|
|
[btdis addTarget:self action:@selector(disAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[viewback mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(btdis);
|
|
}];
|
|
|
|
}
|
|
return self;
|
|
}
|
|
-(void)setStrtitle:(NSString *)strtitle
|
|
{
|
|
self.lbtitle.text = strtitle;
|
|
}
|
|
-(void)setStrinfo:(NSString *)strinfo
|
|
{
|
|
self.lbinfo.text = strinfo;
|
|
}
|
|
-(void)disAction
|
|
{
|
|
[self removeFromSuperview];
|
|
}
|
|
-(void)okAction
|
|
{
|
|
self.backValue(1);
|
|
[self disAction];
|
|
}
|
|
+(void)showName:(NSString *)name strinfo:(NSString *)strinfo back:(TongYiXieYiAlterViewBack)backValue
|
|
{
|
|
TongYiXieYiAlterView *view = [[TongYiXieYiAlterView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT)];
|
|
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
view.strtitle = name;
|
|
view.strinfo = strinfo;
|
|
view.backValue = backValue;
|
|
[app.window addSubview:view];
|
|
}
|
|
@end
|