123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // YOUPAILZVideoDiscountWindow.m
- // VQU
- //
- // Created by CY on 2021/7/16.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZVideoDiscountWindow.h"
- @interface YOUPAILZVideoDiscountWindow ()
- @property (nonatomic,strong) NSArray <UIButton *>*youpaipbtns;
- @property (nonatomic,assign) NSInteger youpaipcurrentIndex;
- @end
- @implementation YOUPAILZVideoDiscountWindow
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.baseView.hidden = YES;
- [self youpaifinitUI];
- }
- - (void)youpaifinitUI{
- UIView *bgV = [[UIView alloc] init];
- bgV.backgroundColor = [UIColor whiteColor];
- bgV.layer.cornerRadius = 10.0f;
- bgV.clipsToBounds = YES;
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(32.0f);
- make.right.offset(-32.0f);
- make.centerY.equalTo(self.view.mas_centerY);
- }];
-
- UILabel *titleL = [[UILabel alloc] init];
- titleL.textColor = HexColorFromRGB(0x333333);
- titleL.font = LCBFont17;
- titleL.textAlignment = NSTextAlignmentCenter;
- titleL.text = @"你可以减免对方的时长费用";
- [bgV addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.top.offset(20.0f);
- }];
-
- UILabel *subtitleL = [[UILabel alloc] init];
- subtitleL.textColor = HexColorFromRGB(0x9F9DA5);
- subtitleL.font = LCFont(14.0f);
- subtitleL.textAlignment = NSTextAlignmentCenter;
- subtitleL.text = [NSString stringWithFormat:@"当前视频价格为:%@钻石/每分钟",self.youpaipmodel.youpaipprice];
- [bgV addSubview:subtitleL];
- [subtitleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.top.equalTo(titleL.mas_bottom).offset(6.0f);
- }];
-
- NSInteger colCount = 3;
- NSInteger totalRow = (self.youpaipmodel.youpaiptime.count + colCount - 1) / colCount;
- CGFloat height = 33.0f * totalRow + (totalRow - 1) * 12.0f;
- UIView *timerBgV = [[UIView alloc] init];
- [bgV addSubview:timerBgV];
- [timerBgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.right.offset(-14.0f);
- make.top.equalTo(subtitleL.mas_bottom).offset(25.0f);
- make.height.offset(height);
- }];
- CGFloat btnWidth = (KScreenWidth - 90.0f + 12.0f) / colCount;
- self.youpaipcurrentIndex = 0;
- NSMutableArray <UIButton *>*btns = [NSMutableArray array];
- for (NSInteger i = 0; i < self.youpaipmodel.youpaiptime.count; i ++) {
- NSInteger col = i % colCount;
- NSInteger row = i / colCount;
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(col * btnWidth, row * 33.0f + row * 12.0f, btnWidth - 12.0f, 33.0f);
- btn.layer.cornerRadius = 16.5f;
- btn.clipsToBounds = YES;
- btn.layer.borderColor = LZF5F4F7Color.CGColor;
- btn.layer.borderWidth = 1.0f;
- btn.backgroundColor = LZF5F4F7Color;
- [btn setTitle:self.youpaipmodel.youpaiptime[i].youpaiptime forState:UIControlStateNormal];
- [btn setTitleColor:LZ273145Color forState:UIControlStateNormal];
- [btn setTitleColor:LZ7C69FEColor forState:UIControlStateSelected];
- btn.titleLabel.font = LCFont14;
- btn.tag = i;
- if (i == self.youpaipcurrentIndex) {
- btn.selected = YES;
- btn.backgroundColor = [LZ7C69FEColor colorWithAlphaComponent:0.1f];
- btn.layer.borderColor = LZ7C69FEColor.CGColor;
- }
- [btn addTarget:self action:@selector(youpaifitemClick:) forControlEvents:UIControlEventTouchUpInside];
- [timerBgV addSubview:btn];
- [btns addObject:btn];
- }
- self.youpaipbtns = btns.copy;
-
- CGFloat width = (KScreenWidth-90.0f-15.0f) / 2.0f;
- UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- cancelBtn.layer.cornerRadius = 24.0f;
- cancelBtn.clipsToBounds = YES;
- cancelBtn.backgroundColor = LZF5F4F7Color;
- [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
- [cancelBtn setTitleColor:LZ273145Color forState:UIControlStateNormal];
- cancelBtn.titleLabel.font = LCFont17;
- [cancelBtn addTarget:self action:@selector(youpaifcancelBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [bgV addSubview:cancelBtn];
- [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14.0f);
- make.top.equalTo(timerBgV.mas_bottom).offset(40.0f);
- make.size.mas_offset(CGSizeMake(width, 48.0f));
- make.bottom.offset(-20.0f);
- }];
-
- UIButton *confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- confirmBtn.layer.cornerRadius = 24.0f;
- confirmBtn.clipsToBounds = YES;
- [confirmBtn setBackgroundImage:[LCTools ColorImage:CGSizeMake(width, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight] forState:UIControlStateNormal];
- [confirmBtn setTitle:@"确认" forState:UIControlStateNormal];
- [confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- confirmBtn.titleLabel.font = LCFont17;
- [confirmBtn addTarget:self action:@selector(youpaifconfirmBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [bgV addSubview:confirmBtn];
- [confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-14.0f);
- make.size.mas_offset(CGSizeMake(width, 48.0f));
- make.bottom.offset(-20.0f);
- }];
- }
- - (void)youpaifitemClick:(UIButton *)sender{
- UIButton *btn = self.youpaipbtns[self.youpaipcurrentIndex];
- btn.selected = NO;
- btn.layer.borderColor = LZF5F4F7Color.CGColor;
- btn.backgroundColor = LZF5F4F7Color;
- self.youpaipcurrentIndex = sender.tag;
- sender.selected = YES;
- sender.backgroundColor = [LZ7C69FEColor colorWithAlphaComponent:0.1f];
- sender.layer.borderColor = LZ7C69FEColor.CGColor;
- }
- - (void)youpaifcancelBtnClick{
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- - (void)youpaifconfirmBtnClick{
- if (self.confirmBtnClickBlock && self.youpaipmodel.youpaiptime.count != 0) {
- self.confirmBtnClickBlock(self.youpaipmodel.youpaiptime[self.youpaipcurrentIndex]);
- }
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- @end
|