底部工具栏效果图
IMG_6379507EBCB4-1.jpeg
自己的自定义弹窗使用
#import "YZMTSelectView.h"
@property(nonatomic,strong)YZMTSelectView * yzSelectView;///<萌图颜值直播的选择控件UI
-(YZMTSelectView *)yzSelectView {
if (_yzSelectView == nil) {
_yzSelectView = [[YZMTSelectView alloc] initWithFrame:CGRectMake(0, Screen_Height - 222, kScreenWidth, 222)];
}
return _yzSelectView;
}
YZMTSelectView.h文件
//
// YZMTSelectView.h
// zhongyou
//
// Created by xiaotang on 2021/4/29.
// Copyright © 2021 mac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "MTUISliderRelatedView.h"
NS_ASSUME_NONNULL_BEGIN
typedef void (^YZMTBlockTapAction) (NSInteger,NSInteger,NSInteger);
typedef NS_ENUM(NSInteger, YZ_MTType) {
YZ_MTType_MY = 0,///<!美颜
YZ_MTType_MX,///<!美型
YZ_MTType_LJ,///<!滤镜
};
@interface YZItemView : UIView
-(void)selectWithStatus:(BOOL)status;
-(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title type:(YZ_MTType)type imgName1:(NSString *)name1 imgName2:(NSString *)name2 status:(BOOL)status indexForI:(NSInteger)i inexForJ:(NSInteger)j block:(YZMTBlockTapAction)block;
@end
@interface YZMTSelectView : UIView
-(instancetype)initWithFrame:(CGRect)frame;
@end
YZMTSelectView.m文件
//
// YZMTSelectView.m
// zhongyou
// https://toivan.com/document.html
// Created by xiaotang on 2021/4/29.
// Copyright © 2021 mac. All rights reserved.
//
#import "YZMTSelectView.h"
@interface YZItemView()<UIGestureRecognizerDelegate>
@property(nonatomic,strong)NSString * name1;
@property(nonatomic,strong)NSString * name2;
@property(nonatomic,assign)NSInteger I;
@property(nonatomic,assign)NSInteger j;
@property(nonatomic,strong)UILabel * bottomLab;
@property(nonatomic,strong)UIImageView * topImg;
@property(nonatomic,assign)YZ_MTType type;
@property(nonatomic,strong)UIImageView * ljSelImg;
@property(nonatomic,copy)YZMTBlockTapAction block;
@property(nonatomic,assign)BOOL status;
@end
@implementation YZItemView
-(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title type:(YZ_MTType)type imgName1:(NSString *)name1 imgName2:(NSString *)name2 status:(BOOL)status indexForI:(NSInteger)i inexForJ:(NSInteger)j block:(YZMTBlockTapAction)block {
self = [super initWithFrame:frame];
if (self) {
_block = block;
[self addSubview:self.topImg];
_name1 = name1;
_name2 = name2;
_type = type;
_i = I;
_j = j;
if (type == YZ_MTType_LJ) {
self.topImg.frame = CGRectMake(0, 25, 50, 50);
self.ljSelImg = [[UIImageView alloc] initWithFrame:CGRectMake(5, 47.5, 40, 5)];
self.ljSelImg.image = [UIImage imageNamed:_name2];
[self addSubview:self.ljSelImg];
}else {
self.topImg.frame = CGRectMake(12.5, 25, 25, 25);
}
self.bottomLab.text = title;
[self addSubview:self.bottomLab];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
tap.delegate = self;
[self addGestureRecognizer:tap];
[self selectWithStatus:status];
}
return self;
}
-(UIImageView *)topImg {
if (_topImg == nil) {
_topImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 25, 50, 50)];
}
return _topImg;
}
-(UILabel *)bottomLab {
if (_bottomLab == nil) {
_bottomLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 100 - 20, 50, 20)];
_bottomLab.font = [UIFont systemFontOfSize:14];
_bottomLab.textAlignment = NSTextAlignmentCenter;
}
return _bottomLab;
}
-(void)tapAction:(UITapGestureRecognizer *)tap {
if (self.status) {
return;
}else{
if (self.block) {
NSInteger type = (NSInteger)_type;
self.block(_i,_j,type);
}
[self selectWithStatus:YES];
}
}
- (void)selectWithStatus:(BOOL)status {
_status = status;
if (status) {
self.bottomLab.textColor = UIColorHex(0x0E76F1);
if (_type == YZ_MTType_LJ) {
self.ljSelImg.hidden = !status;
self.topImg.alpha = 0.5;
self.topImg.image = [UIImage imageNamed:_name1];
}else {
self.topImg.image = [UIImage imageNamed:_name2];
}
}else {
self.bottomLab.textColor = UIColorHex(0x575779);
if (_type == YZ_MTType_LJ) {
self.ljSelImg.hidden = !status;
self.topImg.alpha = 1;
self.topImg.image = [UIImage imageNamed:_name1];
}else {
self.topImg.image = [UIImage imageNamed:_name1];
}
}
}
@end
@interface YZMTSelectView()<UIGestureRecognizerDelegate>
@property(nonatomic,strong)MTUISliderRelatedView * yzSeliderView;
@property(nonatomic,strong)UIView * topSelectView;
@property(nonatomic,strong)UIView * contentSelectView;
@property(nonatomic,strong)NSMutableArray * btnsArr;
@property(nonatomic,strong)UIView * indexView;
@property(nonatomic,assign)NSInteger index;
@property(nonatomic,assign)NSInteger jndex;
@property(nonatomic,assign)NSInteger selmtID;
@property(nonatomic,strong)NSString * sliderDir;
@property(nonatomic,strong)UIScrollView * contentScrollView;
@property(nonatomic,strong)UIView * myView;
@property(nonatomic,strong)UIView * mxView;
@property(nonatomic,strong)UIView * ljView;
@property(nonatomic,strong)UIView * bottomView;
@end
@implementation YZMTSelectView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
[self initArrInfo];
[self configUI];
}
return self;
}
-(void)configUI {
// lazy
[self addSubview:self.topSelectView];
[self addSubview:self.contentSelectView];
UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(15, 39.5, kScreenWidth - 30, 0.5)];
lineView.backgroundColor = UIColorHex(0xEEEEEE);
[self.topSelectView addSubview:lineView];
self.contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(15, 40 + 32, kScreenWidth - 30, 100)];
self.contentScrollView.scrollEnabled = YES;
self.contentScrollView.showsHorizontalScrollIndicator = NO;
[self addSubview:self.contentScrollView];
CGFloat k = 0.0;
for (int i = 0 ; i < _btnsArr.count; i ++) {
NSDictionary * dic = _btnsArr[I];
NSString * title = dic[@"title"];
NSString * selected = dic[@"selected"];
UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(60 * i, 5, 60, 30)];
button.tag = 500 + I;
[button setTitle:title forState:(UIControlStateNormal)];
[button addTarget:self action:@selector(btnAction:) forControlEvents:(UIControlEventTouchUpInside)];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
[self.topSelectView addSubview:button];
if ([selected isEqualToString:@"1"]) {
self.index = I;
[button.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
[self.topSelectView addSubview:self.indexView];
self.indexView.frame = CGRectMake(60 * i + 45 / 2, 38, 15, 2);
}else{
[button.titleLabel setFont:[UIFont systemFontOfSize:14]];
}
NSArray * array = dic[@"arr"];
NSInteger count = array.count;
switch (i) {
case 0:{
self.myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, count * 60 - 8 , 100)];
k = count * 60;
[self.contentScrollView addSubview:self.myView];
for (int j = 0 ; j < array.count; j ++) {
NSDictionary * dic_j = array[j];
NSString * title_j = dic_j[@"name"];
NSString * selected_j = dic_j[@"selected"];
BOOL status = NO;
if ([selected_j isEqualToString:@"1"]) {
status = YES;
if (self.index == i) {
self.jndex = j;
NSString * selID = dic_j[@"currentID"];
self.selmtID = [selID integerValue];
}
}
NSString * name1 = dic_j[@"thumb"];
NSString * name2 = dic_j[@"thumbed"];
WS(weakSelf);
YZItemView * view = [[YZItemView alloc] initWithFrame:CGRectMake(j * 60 , 0, 50, 100) title:title_j type:YZ_MTType_MY imgName1:name1 imgName2:name2 status:status indexForI:i inexForJ:j block:^(NSInteger indexI, NSInteger indexJ, NSInteger indexType) {
[weakSelf dealInfoWithI:indexI J:indexJ T:indexType];
}];
view.tag = [self tagByI:i andJ:j];
[self.myView addSubview:view];
if ([selected isEqualToString:@"1"]) {
self.myView.hidden = NO;
}else {
self.myView.hidden = YES;
}
}
}
break;
case 1:{
self.mxView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, count * 60 - 8 , 100)];
k = MAX(k, count * 60);
[self.contentScrollView addSubview:self.mxView];
for (int j = 0 ; j < array.count; j ++) {
NSDictionary * dic_j = array[j];
NSString * title_j = dic_j[@"name"];
NSString * selected_j = dic_j[@"selected"];
BOOL status = NO;
if ([selected_j isEqualToString:@"1"]) {
status = YES;
if (self.index == i) {
self.jndex = j;
NSString * selID = dic_j[@"currentID"];
self.selmtID = [selID integerValue];
}
}
NSString * name1 = dic_j[@"thumb"];
NSString * name2 = dic_j[@"thumbed"];
WS(weakSelf);
YZItemView * view = [[YZItemView alloc] initWithFrame:CGRectMake(j * 60 , 0, 50, 100) title:title_j type:YZ_MTType_MX imgName1:name1 imgName2:name2 status:status indexForI:i inexForJ:j block:^(NSInteger indexI, NSInteger indexJ, NSInteger indexType) {
[weakSelf dealInfoWithI:indexI J:indexJ T:indexType];
}];
view.tag = [self tagByI:i andJ:j];
[self.mxView addSubview:view];
}
if ([selected isEqualToString:@"1"]) {
self.mxView.hidden = NO;
}else {
self.mxView.hidden = YES;
}
}
break;
case 2:{
self.ljView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, count * 60 - 8 , 100)];
k = MAX(k, count * 60);
[self.contentScrollView addSubview:self.ljView];
for (int j = 0 ; j < array.count; j ++) {
NSDictionary * dic_j = array[j];
NSString * title_j = dic_j[@"name"];
NSString * selected_j = dic_j[@"selected"];
BOOL status = NO;
if ([selected_j isEqualToString:@"1"]) {
status = YES;
if (self.index == i) {
self.jndex = j;
NSString * selID = dic_j[@"currentID"];
self.selmtID = [selID integerValue];
}
}
NSString * name1 = dic_j[@"thumb"];
NSString * name2 = dic_j[@"thumbed"];
WS(weakSelf);
YZItemView * view = [[YZItemView alloc] initWithFrame:CGRectMake(j * 60 , 0, 50, 100) title:title_j type:YZ_MTType_LJ imgName1:name1 imgName2:name2 status:status indexForI:i inexForJ:j block:^(NSInteger indexI, NSInteger indexJ, NSInteger indexType) {
[weakSelf dealInfoWithI:indexI J:indexJ T:indexType];
}];
view.tag = [self tagByI:i andJ:j];
[self.ljView addSubview:view];
}
if ([selected isEqualToString:@"1"]) {
self.ljView.hidden = NO;
}else {
self.ljView.hidden = YES;
}
}
break;
default:
break;
}
self.contentScrollView.contentSize = CGSizeMake(k, 100);
}
[self addSubview:self.bottomView];
UIButton * cz = [UIButton buttonWithType:UIButtonTypeCustom];
cz.frame = CGRectMake(15, 7, 40, 40);
[cz setImage:[UIImage imageNamed:@"yz_mt_icon_cz"] forState:UIControlStateNormal];
[cz addTarget:self action:@selector(refrashActionForSlider) forControlEvents:(UIControlEventTouchUpInside)];
[self.bottomView addSubview:cz];
UILabel * labNoti = [[UILabel alloc] initWithFrame:CGRectMake(55, 17, 50, 20)];
labNoti.textAlignment = NSTextAlignmentLeft;
labNoti.text = @"重置";
labNoti.textColor = UIColorHex(#575779);
labNoti.font = [UIFont systemFontOfSize:12];
[self.bottomView addSubview:labNoti];
UITapGestureRecognizer * tapRefrash = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(refrashActionForSlider)];
tapRefrash.delegate = self;
labNoti.userInteractionEnabled = YES;
[labNoti addGestureRecognizer:tapRefrash];
UIButton * hiddenBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
hiddenBtn.frame = CGRectMake(Screen_Width - 55, 7, 40, 40);
[hiddenBtn setImage:[UIImage imageNamed:@"yz_mt_icon_fh"] forState:(UIControlStateNormal)];
[self.bottomView addSubview:hiddenBtn];
[hiddenBtn addTarget:self action:@selector(hiddenAction) forControlEvents:(UIControlEventTouchUpInside)];
// slider
[self configSliderUI];
}
-(void)dealInfoWithI:(NSInteger)i J:(NSInteger)j T:(NSInteger)t {
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithDictionary:_btnsArr[self.index]];
NSArray * arr = dic[@"arr"];
NSMutableArray * arrNeed = [NSMutableArray arrayWithArray:arr];
for (int c_j = 0 ; c_j < arr.count; c_j ++) {
NSDictionary * dic = arr[c_j];
NSString * selected = dic[@"selected"];
if ([selected isEqualToString:@"1"]) {
NSInteger tag = [self tagByI:self.index andJ:c_j];
if (j == c_j) {
return;
}else{
NSMutableDictionary * dicRep = [NSMutableDictionary dictionaryWithDictionary:dic];
[dicRep setValue:@"0" forKey:@"selected"];
[arrNeed replaceObjectAtIndex:c_j withObject:dicRep];
YZItemView * item = (YZItemView *)[self viewWithTag:tag];
[item selectWithStatus:NO];
}
}
}
NSMutableDictionary * dicClick = [NSMutableDictionary dictionaryWithDictionary:arr[j]];
[dicClick setValue:@"1" forKey:@"selected"];
[arrNeed replaceObjectAtIndex:j withObject:dicClick];
[dic setValue:arrNeed forKey:@"arr"];
[_btnsArr replaceObjectAtIndex:self.index withObject:dic];
self.jndex = j;
self.selmtID = [dicClick[@"currentID"] integerValue];
[self.yzSeliderView removeFromSuperview];
self.yzSeliderView = nil;
[self addSubview:self.yzSeliderView];
if (i == 0 && j == 0) {
[[MtSDK Get] setFaceBeautyEnable:NO];
}else {
[[MtSDK Get] setFaceBeautyEnable:YES];
}
if (i == 1 && j == 0) {
[[MtSDK Get] setFaceShapeEnable:NO];
}else {
[[MtSDK Get] setFaceShapeEnable:YES];
}
}
#pragma mark -- lazy UI
-(UIView *)topSelectView {
if (_topSelectView == nil) {
_topSelectView = [[UIView alloc] initWithFrame:CGRectMake(0, 32, Screen_Width, 40)];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_topSelectView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15,15)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = _topSelectView.bounds;
maskLayer.path = maskPath.CGPath;
_topSelectView.layer.mask = maskLayer;
_topSelectView.backgroundColor = [UIColor whiteColor];
}
return _topSelectView;
}
-(UIView *)indexView {
if (_indexView == nil) {
_indexView = [[UIView alloc] init];
_indexView.backgroundColor = [UIColor colorWithRed:14/255.0 green:118/255.0 blue:241/255.0 alpha:1.0];
}
return _indexView;
}
-(UIView *)contentSelectView {
if (_contentSelectView == nil) {
_contentSelectView = [[UIView alloc] initWithFrame:CGRectMake(0, 40 + 32, kScreenWidth, 140)];
_contentSelectView.backgroundColor = [UIColor whiteColor];
}
return _contentSelectView;
}
-(void)btnAction:(UIButton *)clickedBtn {
WS(weakSelf);
NSInteger tag = clickedBtn.tag;
NSInteger index = tag - 500;
if (index == self.index) {
return;
}
// 按钮的字体大小互相改变
// 底部指示器的view位置发生改变
UIButton * oldSelectedBtn = (UIButton *)[self viewWithTag:self.index + 500];
[UIView animateWithDuration:0.25 animations:^{
[oldSelectedBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
[clickedBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
self.indexView.frame = CGRectMake(60 * index + 45 / 2, 38, 15, 2);
switch (self.index) {
case 0:{
self.myView.hidden = YES;
}
break;
case 1:{
self.mxView.hidden = YES;
}
break;
case 2:{
self.ljView.hidden = YES;
}
break;
default:
break;
}
switch (index) {
case 0:{
self.myView.hidden = NO;
}
break;
case 1:{
self.mxView.hidden = NO;
}
break;
case 2:{
self.ljView.hidden = NO;
}
break;
default:
break;
}
}];
// array发生改变
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithDictionary:self.btnsArr[index]];
[dic setValue:@"1" forKey:@"selected"];
[self.btnsArr replaceObjectAtIndex:index withObject:dic];
NSDictionary * dic2 = [NSMutableDictionary dictionaryWithDictionary: self.btnsArr[self.index]];
[dic2 setValue:@"0" forKey:@"selected"];
[self.btnsArr replaceObjectAtIndex:self.index withObject:dic2];
self.index = index;
NSLog(@"%@ self.index = %ld",_btnsArr,self.index);
CGFloat wid = [dic[@"wid"] floatValue];
if (wid < (Screen_Width - 30)) {
wid = Screen_Width - 29;
}
[self.contentScrollView scrollToLeft];
self.contentScrollView.contentSize = CGSizeMake(wid, 100);
// 新的index下
// 滑块类型根据数据展示
NSDictionary * dicNew = _btnsArr[self.index];
NSArray * arrNew = dicNew[@"arr"];
for (int j = 0 ; j < arrNew.count; j ++) {
NSDictionary * dic = arrNew[j];
NSString * selected = dic[@"selected"];
if ([selected isEqualToString:@"1"]) {
self.jndex = j;
NSString * currentID = dicNew[@"currentID"];
self.selmtID = [currentID integerValue];
}
}
[self.yzSeliderView removeFromSuperview];
self.yzSeliderView = nil;
[self addSubview:self.yzSeliderView];
}
-(void)refrashActionForSlider {
NSInteger i = self.index;
NSInteger j = self.jndex;
NSDictionary * dic = _btnsArr[I];
NSArray * arr = dic[@"arr"];
NSDictionary * dicJ = arr[j];
NSString * sliderValue = dicJ[@"sliderdef"];
NSMutableDictionary * dicSave = [NSMutableDictionary dictionaryWithDictionary:dicJ];
[dicSave setValue:sliderValue forKey:@"sliderValue"];
NSMutableArray * arraySave = [NSMutableArray arrayWithArray:arr];
[arraySave replaceObjectAtIndex:j withObject:dicSave];
NSMutableDictionary * dicSS = [NSMutableDictionary dictionaryWithDictionary:dic];
[dicSS setValue:arraySave forKey:@"arr"];
[_btnsArr replaceObjectAtIndex:i withObject:dicSS];
[self.yzSeliderView removeFromSuperview];
self.yzSeliderView = nil;
[self addSubview:self.yzSeliderView];
}
-(NSInteger )tagByI:(NSInteger)i andJ:(NSInteger)j {
NSInteger tag = 600 + (i + 1) * 100 + j;
return tag;
}
-(void)configSliderUI {
[self addSubview:self.yzSeliderView];
}
-(void)initArrInfo {
_btnsArr = [NSMutableArray arrayWithArray:@[
@{@"title":@"美颜",@"arr":@[
@{@"name": @"原图",@"selected": @"1",@"thumb": @"yz_mt_icon_yt_1",@"thumbed":@"yz_mt_icon_yt_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"1",@"currentID":@"1",@"sliderdef":@"50"},
@{@"name": @"美白",@"selected": @"0",@"thumb": @"yz_mt_icon_mb_1",@"thumbed":@"yz_mt_icon_mb_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"1",@"currentID":@"101",@"sliderdef":@"50"},
@{@"name": @"磨皮",@"selected": @"0",@"thumb": @"yz_mt_icon_mp_1",@"thumbed":@"yz_mt_icon_mp_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"1",@"currentID":@"102",@"sliderdef":@"50"},
@{@"name": @"红润",@"selected": @"0",@"thumb": @"yz_mt_icon_hr_1",@"thumbed":@"yz_mt_icon_hr_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"1",@"currentID":@"103",@"sliderdef":@"50"},
@{@"name": @"鲜明",@"selected": @"0",@"thumb": @"yz_mt_icon_xm_1",@"thumbed":@"yz_mt_icon_xm_2",@"sliderType":@"2",@"sliderValue":@"0",@"fatherID":@"1",@"currentID":@"104",@"sliderdef":@"0"},
@{@"name": @"亮度",@"selected": @"0",@"thumb": @"yz_mt_icon_ld_1",@"thumbed":@"yz_mt_icon_ld_2",@"sliderType":@"2",@"sliderValue":@"0",@"fatherID":@"1",@"currentID":@"105",@"sliderdef":@"0"}],
@"selected":@"1",@"wid":@300,@"index":@0},
@{@"title":@"美型",@"arr":@[
@{@"name": @"原图",@"selected": @"1",@"thumb": @"yz_mt_icon_yt_1",@"thumbed":@"yz_mt_icon_yt_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"2",@"currentID":@"2",@"sliderdef":@"50"},
@{@"name": @"大眼",@"selected": @"0",@"thumb": @"yz_mt_icon_dy_1",@"thumbed":@"yz_mt_icon_dy_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"2",@"currentID":@"201",@"sliderdef":@"50"},
@{@"name": @"瘦脸",@"selected": @"0",@"thumb": @"yz_mt_icon_sl_1",@"thumbed":@"yz_mt_icon_sl_2",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"2",@"currentID":@"202",@"sliderdef":@"50"},
@{@"name": @"倾斜",@"selected": @"0",@"thumb": @"yz_mt_icon_qx_1",@"thumbed":@"yz_mt_icon_qx_2",@"sliderType":@"2",@"sliderValue":@"0",@"fatherID":@"2",@"currentID":@"213",@"sliderdef":@"0"},
@{@"name": @"微笑唇",@"selected": @"0",@"thumb": @"yz_mt_icon_wxc_1",@"thumbed":@"yz_mt_icon_wxc_2",@"sliderType":@"2",@"sliderValue":@"0",@"fatherID":@"2",@"currentID":@"220",@"sliderdef":@"0"},
@{@"name": @"山根",@"selected": @"0",@"thumb": @"yz_mt_icon_sg_1",@"thumbed":@"yz_mt_icon_sg_2",@"sliderType":@"2",@"sliderValue":@"0",@"fatherID":@"2",@"currentID":@"218",@"sliderdef":@"0"}],
@"selected":@"0",@"wid":@300,@"index":@0},
@{@"title":@"滤镜",@"arr":@[
@{@"name": @"原图",@"selected": @"1",@"thumb": @"mt_nobeautyfilter_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"",@"sliderdef":@"50"},
@{@"name": @"美白",@"selected": @"0",@"thumb": @"mt_white_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"white",@"sliderdef":@"50"},
@{@"name": @"日系",@"selected": @"0",@"thumb": @"mt_rixi_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"rixi",@"sliderdef":@"50"},
@{@"name": @"清凉",@"selected": @"0",@"thumb": @"mt_qingliang_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"qingliang",@"sliderdef":@"50"},
@{@"name": @"香氛",@"selected": @"0",@"thumb": @"mt_xiangfen_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"xiangfen",@"sliderdef":@"50"},
@{@"name": @"樱红",@"selected": @"0",@"thumb": @"mt_yinghong_icon.png",@"thumbed":@"icon_lvjing_selected",@"sliderType":@"1",@"sliderValue":@"50",@"fatherID":@"3",@"currentID":@"800",@"dir":@"yinghong",@"sliderdef":@"50"}],
@"selected":@"0",@"wid":@300,@"index":@0},
]];
}
-(UIView *)bottomView {
if (_bottomView == nil) {
_bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 172, Screen_Width, 50)];
_bottomView.backgroundColor = [UIColor whiteColor];
}
return _bottomView;
}
-(void)hiddenAction {
self.hidden = YES;
}
-(MTUISliderRelatedView *)yzSeliderView{
if (_yzSeliderView == nil) {
_yzSeliderView = [[MTUISliderRelatedView alloc]init];
_yzSeliderView.frame = CGRectMake(10, 0, kScreenWidth - 20, 32);
//默认美白拉条
WeakObject(_btnsArr, btnsARR);
NSDictionary * dic = _btnsArr[self.index];
NSArray * arr = dic[@"arr"];
NSDictionary * innerDic = arr[self.jndex];
NSString * sliderType = innerDic[@"sliderType"];
NSInteger type = [sliderType integerValue] - 1;
NSString * sliderValue = innerDic[@"sliderValue"];
NSInteger value = [sliderValue integerValue];
if (self.index == 2) {
NSString * dir = [NSString stringWithFormat:@"%@",innerDic[@"dir"]];
if (dir.isNotBlank) {
self.sliderDir = dir;
}else {
self.sliderDir = @"";
}
}else {
self.sliderDir = @"";
}
[_yzSeliderView.sliderView setSliderType:type WithValue:value];
__weak typeof(self) weakSelf = self;//滑动拉条调用成回调
[_yzSeliderView.sliderView setRefreshValueBlock:^(CGFloat value) {
// 设置美颜参数
MTTotalModel * model = [[MTTotalModel alloc] init];
if (weakSelf.selmtID == 800) {
if (weakSelf.sliderDir.isNotBlank) {
model.dir = weakSelf.sliderDir;
}else{
model.dir = @"";
}
}
[MTSetSDK setBeautySlider:value forKey:weakSelf.selmtID withMod:model isDidEnd:NO];
}];
//结束拖拽时最终值
[_yzSeliderView.sliderView setDidEndUpdateValueBlock:^(CGFloat value) {
//设置美颜参数
MTTotalModel * model = [[MTTotalModel alloc] init];
if (weakSelf.selmtID == 800) {
if (weakSelf.sliderDir.isNotBlank) {
model.dir = weakSelf.sliderDir;
}else{
model.dir = @"";
}
}
[MTSetSDK setBeautySlider:value forKey:weakSelf.selmtID withMod:model isDidEnd:YES];
NSDictionary * dicG = btnsARR[weakSelf.index];
NSArray * arrG = dicG[@"arr"];
NSMutableDictionary * dic = [NSMutableDictionary dictionaryWithDictionary:arrG[weakSelf.jndex]];
[dic setValue:[NSString stringWithFormat:@"%f",value] forKey:@"sliderValue"];
NSMutableArray * arrSave = [NSMutableArray arrayWithArray:arrG];
[arrSave replaceObjectAtIndex:weakSelf.jndex withObject:dic];
NSMutableDictionary * dicSave = [NSMutableDictionary dictionaryWithDictionary:dicG];
[dicSave setValue:arrSave forKey:@"arr"];
[btnsARR replaceObjectAtIndex:weakSelf.index withObject:dicSave];
}];
}
return _yzSeliderView;
}
@end
网友评论