123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // YMImproveInfoGenderView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/9.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMImproveInfoGenderView.h"
- #import "YMImproveInfoViewModel.h"
- @interface YMImproveInfoGenderView ()<YMChoiceButtonDelegate>
- /// 完善信息VM
- @property (nonatomic, strong) YMImproveInfoViewModel *viewModel;
- /// 男性单选按钮
- @property (nonatomic, strong) YMChoiceButton *maleChoiceBtn;
- /// 女性单选按钮
- @property (nonatomic, strong) YMChoiceButton *femaleChoiceBtn;
- @property (nonatomic, strong) UILabel *genderTitleLb;
- @end
- @implementation YMImproveInfoGenderView
- - (void)ym_setupViews{
- [self addSubview:self.genderTitleLb];
- [self addSubview:self.maleChoiceBtn];
- [self addSubview:self.femaleChoiceBtn];
-
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
-
- [self.genderTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self);
- make.left.equalTo(self);
- make.height.mas_equalTo(adapt(25));
- }];
-
- [self.maleChoiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.genderTitleLb.mas_bottom);
- make.left.equalTo(self);
- make.width.mas_equalTo(adapt(148));
- make.height.mas_equalTo(adapt(50));
- }];
-
- [self.femaleChoiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.genderTitleLb.mas_bottom);
- make.right.equalTo(self);
- make.width.mas_equalTo(adapt(148));
- make.height.mas_equalTo(adapt(50));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMImproveInfoViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
- _viewModel = viewModel;
- self.maleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0x000000);
- self.femaleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0xF8F8F8);
-
- }
- - (void)ym_choiceButtonSelectedAtIndex:(NSUInteger)index inGroup:(NSString *)groupId{
- switch (index) {
- case 2:
- {
- self.maleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0x000000);
- self.femaleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0xF8F8F8);
- }
- break;
- case 1:
- {
- self.femaleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0x000000);
- self.maleChoiceBtn.backgroundColor = UIColor.clearColor;//HexColorFromRGB(0xF8F8F8);
-
- }
- break;
- default:
- break;
- }
-
- self.viewModel.genderType = index;
- dispatch_async(dispatch_get_main_queue(), ^{
- [[YMGlobalUtils getCurrentVC].view endEditing:YES];
- });
- }
- - (void)ym_choiceButtonCancelAtIndex:(NSUInteger)index inGroup:(NSString *)groupId{
-
- }
- - (UILabel *)genderTitleLb{
- if (!_genderTitleLb) {
- _genderTitleLb = [[UILabel alloc]init];
- _genderTitleLb.font = LCFont(15);
- _genderTitleLb.textColor = HexColorFromRGBA(0x000000,0.3);
- _genderTitleLb.textAlignment = NSTextAlignmentLeft;
- _genderTitleLb.textAlignment = NSTextAlignmentLeft;
- _genderTitleLb.text = @"性别(注册后不可修改)";
- }
- return _genderTitleLb;
- }
- - (YMChoiceButton *)maleChoiceBtn{
- if (!_maleChoiceBtn) {
- _maleChoiceBtn = [YMChoiceButton buttonWithFrame:CGRectZero andChoiceType:YMChoiceTypeRadio withIndex:2 inGroup:@"gender" withSelectedImage:ImageByName(@"ym_improve_info_male_selected_icon") andNormalImage:ImageByName(@"ym_improve_info_male_normal_icon")];
- //[_maleChoiceBtn setTitle:@"男生" forState:UIControlStateNormal];
- //_maleChoiceBtn.titleLabel.font = LCBoldFont(17);
- //[_maleChoiceBtn setTitleColor:HexColorFromRGB(0x77F99A) forState:UIControlStateNormal];
- //_maleChoiceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- //[_maleChoiceBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
- //CGFloat margin = 3;
- //_maleChoiceBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
- _maleChoiceBtn.selected = YES;
- _maleChoiceBtn.mustChooseOne = YES;
- _maleChoiceBtn.layer.cornerRadius = adapt(11);
- _maleChoiceBtn.layer.masksToBounds = true;
- _maleChoiceBtn.delegate = self;
- }
- return _maleChoiceBtn;
- }
- - (YMChoiceButton *)femaleChoiceBtn{
- if (!_femaleChoiceBtn) {
- _femaleChoiceBtn = [YMChoiceButton buttonWithFrame:CGRectZero andChoiceType:YMChoiceTypeRadio withIndex:1 inGroup:@"gender" withSelectedImage:ImageByName(@"ym_improve_info_female_selected_icon") andNormalImage:ImageByName(@"ym_improve_info_female_normal_icon")];
- //[_femaleChoiceBtn setTitle:@"女生" forState:UIControlStateNormal];
- //_femaleChoiceBtn.titleLabel.font = LCBoldFont(17);
- //[_femaleChoiceBtn setTitleColor:HexColorFromRGB(0xF7798B) forState:UIControlStateNormal];
- //_femaleChoiceBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- //[_femaleChoiceBtn setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
- //CGFloat margin = 3;
- //_femaleChoiceBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -margin, 0, margin);
- _femaleChoiceBtn.mustChooseOne = YES;
- _femaleChoiceBtn.delegate = self;
- _femaleChoiceBtn.layer.cornerRadius = adapt(11);
- _femaleChoiceBtn.layer.masksToBounds = true;
- }
- return _femaleChoiceBtn;
- }
- @end
|