123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // LDGuideView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/8.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "LDGuideView.h"
- #import "UIButton+ImageTitleStyle.h"
- @implementation LDGuideView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
- // UIImageView *titleIcon = [[UIImageView alloc] init];
- // titleIcon.image = [UIImage imageNamed:@"guideTitle"];
- // [self addSubview:titleIcon];
-
- UILabel *titleLb = [[UILabel alloc] init];
- titleLb.font = [UIFont systemFontOfSize:16];
- titleLb.textAlignment = NSTextAlignmentCenter;
- titleLb.textColor = [UIColor homeRedColor];
- titleLb.text = @"猎豆优选更懂你";
- [self addSubview:titleLb];
-
- UILabel *label = [[UILabel alloc] init];
- label.text = @"选择性别进入app";
- label.textAlignment = NSTextAlignmentCenter;
- label.textColor = [UIColor YHColorWithHex:0x999999];
- label.font = [UIFont systemFontOfSize:12];
- [self addSubview:label];
-
- UIButton *manBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [manBtn setTitle:@"我是帅哥" forState:UIControlStateNormal];
- [manBtn setImage:[UIImage imageNamed:@"guide_boy"] forState:UIControlStateNormal];
- manBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- [manBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
- [manBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
- manBtn.tag = 1001;
- [self addSubview:manBtn];
-
-
- UIButton *womanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [womanBtn setTitle:@"我是美女" forState:UIControlStateNormal];
- [womanBtn setImage:[UIImage imageNamed:@"guide_girl"] forState:UIControlStateNormal];
- womanBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- [womanBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
- [womanBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
- womanBtn.tag = 1000;
- [self addSubview:womanBtn];
-
- [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(FITSIZE(128));
- make.width.mas_equalTo(150);
- make.height.mas_equalTo(20);
- make.centerX.mas_equalTo(self.mas_centerX);
- }];
-
- [label mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleLb.mas_bottom).mas_offset(15);
- make.centerX.mas_equalTo(self.mas_centerX);
- make.width.mas_equalTo(300);
- }];
-
- [manBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(FITSIZE(70));
- make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(77));
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(120);
- }];
- [manBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:0];
-
- [womanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(FITSIZE(-70));
- make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(77));
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(120);
- }];
- [womanBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:0];
- }
- - (void)changeSexAction:(UIButton *)sender {
-
- NSString *sexStr = [NSString stringWithFormat:@"%ld",sender.tag-1000];
- [[NSUserDefaults standardUserDefaults] setObject:sexStr forKey:UserSexKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
-
- [UIView animateWithDuration:1.5 animations:^{
- self.alpha = 0;
- }];
-
- }
- @end
|