1
This commit is contained in:
@@ -36,11 +36,11 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
|
||||
|
||||
// 首次安装先进入性别选择页;点击 Skip 或确认后再进入主 TabBar
|
||||
BOOL hasShownSexVC = [[NSUserDefaults standardUserDefaults] boolForKey:KBSexSelectShownKey];
|
||||
if (hasShownSexVC) {
|
||||
[self setupRootVC];
|
||||
} else {
|
||||
// if (hasShownSexVC) {
|
||||
// [self setupRootVC];
|
||||
// } else {
|
||||
[self setupSexSelectRootVC];
|
||||
}
|
||||
// }
|
||||
|
||||
// 主工程默认开启网络总开关(键盘扩展仍需用户允许完全访问后再行开启)
|
||||
[KBNetworkManager shared].enabled = YES;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
@interface KBSexSelVC ()
|
||||
|
||||
// 顶部区域
|
||||
@property (nonatomic, strong) UIView *topBgView; // 顶部背景(渐变)
|
||||
@property (nonatomic, strong) UIImageView *arrowImageView; // 右上角箭头
|
||||
@property (nonatomic, strong) UILabel *titleLabel; // 标题文案
|
||||
@property (nonatomic, strong) UIView *titleUnderlineView; // 标题下划线
|
||||
@@ -36,7 +35,8 @@
|
||||
@property (nonatomic, strong) UIButton *confirmButton; // Turn On The Keyboard 按钮
|
||||
|
||||
// 渐变层
|
||||
@property (nonatomic, strong) CAGradientLayer *topGradientLayer;
|
||||
//@property (nonatomic, strong) CAGradientLayer *topGradientLayer;
|
||||
@property (nonatomic, strong) UIImageView *bgImageView; // 全屏背景图
|
||||
|
||||
@end
|
||||
|
||||
@@ -47,14 +47,19 @@
|
||||
// 使用全屏内容,不需要自定义导航栏
|
||||
self.kb_enableCustomNavBar = NO;
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
|
||||
self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.view addSubview:self.bgImageView];
|
||||
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.view);
|
||||
}];
|
||||
[self setupUI];
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
// 更新渐变背景尺寸
|
||||
self.topGradientLayer.frame = self.topBgView.bounds;
|
||||
// self.topGradientLayer.frame = self.topBgView.bounds;
|
||||
}
|
||||
|
||||
#pragma mark - Setup UI
|
||||
@@ -62,126 +67,109 @@
|
||||
/// 构建静态 UI 布局
|
||||
- (void)setupUI {
|
||||
// 顶部区域
|
||||
[self.view addSubview:self.topBgView];
|
||||
[self.topBgView addSubview:self.arrowImageView];
|
||||
[self.topBgView addSubview:self.titleLabel];
|
||||
[self.topBgView addSubview:self.titleUnderlineView];
|
||||
[self.view addSubview:self.arrowImageView];
|
||||
[self.view addSubview:self.titleLabel];
|
||||
[self.view addSubview:self.titleUnderlineView];
|
||||
[self.view addSubview:self.skipButton];
|
||||
|
||||
// 三个性别卡片
|
||||
[self.view addSubview:self.maleCardView];
|
||||
[self.maleCardView addSubview:self.maleImageView];
|
||||
[self.view addSubview:self.maleImageView];
|
||||
[self.maleCardView addSubview:self.maleLabel];
|
||||
|
||||
[self.view addSubview:self.femaleCardView];
|
||||
[self.femaleCardView addSubview:self.femaleImageView];
|
||||
[self.view addSubview:self.femaleImageView];
|
||||
[self.femaleCardView addSubview:self.femaleLabel];
|
||||
|
||||
[self.view addSubview:self.otherCardView];
|
||||
[self.otherCardView addSubview:self.otherLeftImageView];
|
||||
[self.otherCardView addSubview:self.otherRightImageView];
|
||||
[self.view addSubview:self.otherLeftImageView];
|
||||
[self.view addSubview:self.otherRightImageView];
|
||||
[self.otherCardView addSubview:self.otherLabel];
|
||||
|
||||
|
||||
// 底部按钮
|
||||
[self.view addSubview:self.confirmButton];
|
||||
|
||||
// 顶部背景
|
||||
[self.topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.view);
|
||||
make.top.equalTo(self.view);
|
||||
make.height.mas_equalTo(240);
|
||||
}];
|
||||
|
||||
|
||||
// 跳过按钮右上角(跟随安全区)
|
||||
[self.skipButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
if (@available(iOS 11.0, *)) {
|
||||
make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(8);
|
||||
} else {
|
||||
make.top.equalTo(self.view).offset(30);
|
||||
}
|
||||
make.top.equalTo(self.view).offset(54);
|
||||
make.right.equalTo(self.view).offset(-16);
|
||||
make.height.mas_equalTo(32);
|
||||
make.width.mas_greaterThanOrEqualTo(64);
|
||||
}];
|
||||
;
|
||||
|
||||
// 标题居左,靠近顶部背景下方
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(28);
|
||||
make.bottom.equalTo(self.topBgView.mas_bottom).offset(-48);
|
||||
}];
|
||||
|
||||
[self.titleUnderlineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel.mas_left);
|
||||
make.right.lessThanOrEqualTo(self.topBgView).offset(-40);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(8);
|
||||
make.height.mas_equalTo(4);
|
||||
make.centerX.equalTo(self.view);
|
||||
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT + 40);
|
||||
}];
|
||||
|
||||
[self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.topBgView).offset(-40);
|
||||
make.top.equalTo(self.topBgView).offset(40);
|
||||
make.width.mas_equalTo(90);
|
||||
make.height.mas_equalTo(90);
|
||||
make.right.equalTo(self.view).offset(-KBFit(90));
|
||||
make.top.equalTo(self.skipButton).offset(KBFit(15));
|
||||
make.width.mas_equalTo(KBFit(220));
|
||||
make.height.mas_equalTo(KBFit(99));
|
||||
}];
|
||||
|
||||
// 男性卡片
|
||||
[self.maleCardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(20);
|
||||
make.right.equalTo(self.view).offset(-20);
|
||||
make.top.equalTo(self.topBgView.mas_bottom).offset(-10); // 略微上移,产生“压住”效果
|
||||
make.height.mas_equalTo(128);
|
||||
make.top.equalTo(self.arrowImageView.mas_bottom).offset(65);
|
||||
make.height.mas_equalTo(KBFit(88));
|
||||
}];
|
||||
|
||||
[self.maleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.maleCardView).offset(12);
|
||||
make.centerY.equalTo(self.maleCardView);
|
||||
make.left.equalTo(self.maleCardView).offset(20);
|
||||
make.bottom.equalTo(self.maleCardView).offset(-2);
|
||||
make.width.mas_equalTo(110);
|
||||
make.height.mas_equalTo(110);
|
||||
make.height.mas_equalTo(140);
|
||||
}];
|
||||
|
||||
[self.maleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.equalTo(self.maleCardView);
|
||||
make.right.equalTo(self.maleCardView).offset(-24);
|
||||
make.right.equalTo(self.maleCardView).offset(-60);
|
||||
}];
|
||||
|
||||
// 女性卡片
|
||||
[self.femaleCardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.maleCardView);
|
||||
make.top.equalTo(self.maleCardView.mas_bottom).offset(24);
|
||||
make.height.mas_equalTo(110);
|
||||
make.top.equalTo(self.maleCardView.mas_bottom).offset(65);
|
||||
make.height.equalTo(self.maleCardView);
|
||||
}];
|
||||
|
||||
[self.femaleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.femaleCardView).offset(-12);
|
||||
make.centerY.equalTo(self.femaleCardView);
|
||||
make.width.mas_equalTo(110);
|
||||
make.height.mas_equalTo(110);
|
||||
make.bottom.equalTo(self.femaleCardView).offset(-2);
|
||||
make.width.mas_equalTo(120);
|
||||
make.height.mas_equalTo(133);
|
||||
}];
|
||||
|
||||
[self.femaleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.femaleCardView).offset(24);
|
||||
make.left.equalTo(self.femaleCardView).offset(60);
|
||||
make.centerY.equalTo(self.femaleCardView);
|
||||
}];
|
||||
|
||||
// 第三性别卡片
|
||||
[self.otherCardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.maleCardView);
|
||||
make.top.equalTo(self.femaleCardView.mas_bottom).offset(24);
|
||||
make.height.mas_equalTo(96);
|
||||
make.top.equalTo(self.femaleCardView.mas_bottom).offset(47);
|
||||
make.height.equalTo(self.maleCardView);
|
||||
}];
|
||||
|
||||
[self.otherLeftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.otherCardView).offset(16);
|
||||
make.centerY.equalTo(self.otherCardView);
|
||||
make.top.equalTo(self.otherCardView).offset(-15);
|
||||
make.width.mas_equalTo(54);
|
||||
make.height.mas_equalTo(54);
|
||||
make.height.mas_equalTo(72);
|
||||
}];
|
||||
|
||||
[self.otherRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.otherCardView).offset(-16);
|
||||
make.centerY.equalTo(self.otherCardView);
|
||||
make.width.mas_equalTo(54);
|
||||
make.height.mas_equalTo(54);
|
||||
make.right.equalTo(self.otherCardView);
|
||||
make.bottom.equalTo(self.otherCardView);
|
||||
make.width.mas_equalTo(36);
|
||||
make.height.mas_equalTo(41);
|
||||
}];
|
||||
|
||||
[self.otherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -192,12 +180,9 @@
|
||||
// 底部按钮
|
||||
[self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.maleCardView);
|
||||
make.height.mas_equalTo(54);
|
||||
if (@available(iOS 11.0, *)) {
|
||||
make.height.mas_equalTo(60);
|
||||
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-24);
|
||||
} else {
|
||||
make.bottom.equalTo(self.view).offset(-24);
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -225,22 +210,6 @@
|
||||
|
||||
#pragma mark - Lazy UI
|
||||
|
||||
- (UIView *)topBgView {
|
||||
if (!_topBgView) {
|
||||
_topBgView = [UIView new];
|
||||
// 渐变背景(浅绿色 → 纯白)
|
||||
CAGradientLayer *layer = [CAGradientLayer layer];
|
||||
layer.colors = @[
|
||||
(__bridge id)[UIColor colorWithHex:0xE4FFF6].CGColor,
|
||||
(__bridge id)[UIColor colorWithHex:0xFFFFFF].CGColor
|
||||
];
|
||||
layer.startPoint = CGPointMake(0.5, 0.0);
|
||||
layer.endPoint = CGPointMake(0.5, 1.0);
|
||||
[_topBgView.layer insertSublayer:layer atIndex:0];
|
||||
self.topGradientLayer = layer;
|
||||
}
|
||||
return _topBgView;
|
||||
}
|
||||
|
||||
- (UIImageView *)arrowImageView {
|
||||
if (!_arrowImageView) {
|
||||
@@ -318,7 +287,7 @@
|
||||
- (UIView *)femaleCardView {
|
||||
if (!_femaleCardView) {
|
||||
_femaleCardView = [UIView new];
|
||||
_femaleCardView.backgroundColor = [UIColor colorWithHex:0xF6F8FC];
|
||||
_femaleCardView.backgroundColor = [UIColor colorWithHex:0xFAFAFA];
|
||||
_femaleCardView.layer.cornerRadius = 24.0;
|
||||
_femaleCardView.layer.masksToBounds = YES;
|
||||
}
|
||||
@@ -346,7 +315,7 @@
|
||||
- (UIView *)otherCardView {
|
||||
if (!_otherCardView) {
|
||||
_otherCardView = [UIView new];
|
||||
_otherCardView.backgroundColor = [UIColor colorWithHex:0xFDFDFD];
|
||||
_otherCardView.backgroundColor = [UIColor colorWithHex:0xFAFAFA];
|
||||
_otherCardView.layer.cornerRadius = 24.0;
|
||||
_otherCardView.layer.masksToBounds = YES;
|
||||
}
|
||||
@@ -355,7 +324,7 @@
|
||||
|
||||
- (UIImageView *)otherLeftImageView {
|
||||
if (!_otherLeftImageView) {
|
||||
_otherLeftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sex_othersmall_icon"]];
|
||||
_otherLeftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sex_otherbig_icon"]];
|
||||
_otherLeftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _otherLeftImageView;
|
||||
@@ -363,7 +332,7 @@
|
||||
|
||||
- (UIImageView *)otherRightImageView {
|
||||
if (!_otherRightImageView) {
|
||||
_otherRightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sex_otherbig_icon"]];
|
||||
_otherRightImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sex_othersmall_icon"]];
|
||||
_otherRightImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _otherRightImageView;
|
||||
@@ -386,7 +355,7 @@
|
||||
[_confirmButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
_confirmButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightSemibold];
|
||||
_confirmButton.backgroundColor = [UIColor blackColor];
|
||||
_confirmButton.layer.cornerRadius = 27.0;
|
||||
_confirmButton.layer.cornerRadius = 30;
|
||||
_confirmButton.layer.masksToBounds = YES;
|
||||
[_confirmButton addTarget:self action:@selector(onConfirmTapped) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user