// // SPHomeSortSingleView.m // SweetParty // // Created by bj_szd on 2022/5/31. // #import "SPHomeSortSingleView.h" #import "HXTagsView.h" #import "HXTagAttribute.h" @interface SPHomeSortSingleView () @end @implementation SPHomeSortSingleView - (instancetype)initWithType:(NSInteger)type { if (self == [super init]) { [self createUI:type]; } return self; } - (void)createUI:(NSInteger)type { NSString *titleStr = @""; NSArray *btnTitlesArr = @[]; if (type == 1) { titleStr = @"性别"; btnTitlesArr = @[@"不限", @"只看男生", @"只看女生"]; }else if (type == 2) { titleStr = @"距离"; btnTitlesArr = @[@"不限", @"距离优先"]; }else if (type == 3) { titleStr = @"年龄"; btnTitlesArr = @[@"不限", @"18-22岁", @"23-26岁", @"27-35岁", @"35岁以上"]; } UILabel *titleLab = [ControlCreator createLabel:self rect:CGRectZero text:titleStr font:YBBoldFont(16) color:kWhiteColor backguoundColor:nil align:NSTextAlignmentLeft lines:1]; HXTagsView *tagsView = [[HXTagsView alloc] init]; tagsView.tags = btnTitlesArr; tagsView.backgroundColor = kClearColor; tagsView.layout.sectionInset = UIEdgeInsetsMake(0, 26, 0, 26); tagsView.tagAttribute.selectedBackgroundColor = [UIColor bm_colorGradientChangeWithSize:CGSizeMake(90, 30) direction:FXGradientChangeDirectionHorizontal startColor:mainLightColor endColor:mainDeepColor]; WEAK_SELF tagsView.completion = ^(NSArray *selectTags, NSInteger currentIndex) { if (weakSelf.onSelectIndexBlock) { weakSelf.onSelectIndexBlock(currentIndex); } }; [self addSubview:tagsView]; tagsView.originalTags = @[btnTitlesArr.firstObject]; [titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self); make.left.equalTo(self).offset(26); }]; [tagsView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(titleLab.mas_bottom).offset(15); make.left.right.bottom.equalTo(self); }]; } @end