This commit is contained in:
2025-11-17 18:51:06 +08:00
parent ea4b8168b7
commit ee433db4ad
3 changed files with 202 additions and 11 deletions

View File

@@ -7,6 +7,13 @@
#import "KBSexSelVC.h"
///
typedef NS_ENUM(NSInteger, KBSexOption) {
KBSexOptionMale = 0,
KBSexOptionFemale,
KBSexOptionOther
};
@interface KBSexSelVC ()
//
@@ -38,6 +45,9 @@
//@property (nonatomic, strong) CAGradientLayer *topGradientLayer;
@property (nonatomic, strong) UIImageView *bgImageView; //
///
@property (nonatomic, assign) KBSexOption selectedSex;
@end
@implementation KBSexSelVC
@@ -54,6 +64,9 @@
make.edges.equalTo(self.view);
}];
[self setupUI];
// Male
[self kb_updateSelection:KBSexOptionMale];
}
- (void)viewDidLayoutSubviews {
@@ -88,7 +101,14 @@
//
[self.view addSubview:self.confirmButton];
//
UITapGestureRecognizer *tapMale = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onMaleCardTapped)];
[self.maleCardView addGestureRecognizer:tapMale];
UITapGestureRecognizer *tapFemale = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onFemaleCardTapped)];
[self.femaleCardView addGestureRecognizer:tapFemale];
UITapGestureRecognizer *tapOther = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onOtherCardTapped)];
[self.otherCardView addGestureRecognizer:tapOther];
//
@@ -188,6 +208,21 @@
#pragma mark - Actions
///
- (void)onMaleCardTapped {
[self kb_updateSelection:KBSexOptionMale];
}
///
- (void)onFemaleCardTapped {
[self kb_updateSelection:KBSexOptionFemale];
}
///
- (void)onOtherCardTapped {
[self kb_updateSelection:KBSexOptionOther];
}
///
- (void)onSkipTapped {
// AppDelegate TabBar
@@ -208,6 +243,22 @@
[[NSUserDefaults standardUserDefaults] synchronize];
}
/// UI
- (void)kb_updateSelection:(KBSexOption)sex {
self.selectedSex = sex;
[self kb_updateCard:self.maleCardView selected:(sex == KBSexOptionMale)];
[self kb_updateCard:self.femaleCardView selected:(sex == KBSexOptionFemale)];
[self kb_updateCard:self.otherCardView selected:(sex == KBSexOptionOther)];
}
/// /
- (void)kb_updateCard:(UIView *)card selected:(BOOL)selected {
card.layer.borderWidth = selected ? 2.0 : 0.0;
card.layer.borderColor = selected ? [UIColor colorWithHex:KBColorValue].CGColor : [UIColor clearColor].CGColor;
card.backgroundColor = selected ? [UIColor whiteColor] : [UIColor colorWithHex:0xFAFAFA];
}
#pragma mark - Lazy UI
@@ -257,10 +308,12 @@
- (UIView *)maleCardView {
if (!_maleCardView) {
_maleCardView = [UIView new];
_maleCardView.backgroundColor = [UIColor whiteColor];
//
_maleCardView.backgroundColor = [UIColor colorWithHex:0xFAFAFA];
_maleCardView.layer.cornerRadius = 24.0;
_maleCardView.layer.masksToBounds = YES;
_maleCardView.layer.borderWidth = 2.0;
// kb_updateSelection
_maleCardView.layer.borderWidth = 0.0;
_maleCardView.layer.borderColor = [UIColor colorWithHex:KBColorValue].CGColor;
}
return _maleCardView;