123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- //
- // DRGuideView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/8.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRGuideView.h"
- #import "UIButton+ImageTitleStyle.h"
- @implementation DRGuideView
- - (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];
- NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- titleLb.text = [NSString stringWithFormat:@"%@更懂你",app_Name];
- [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:Fitsize(14)];
- manBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
- [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:Fitsize(14)];
- womanBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
- [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(100));
- 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(52));
- make.width.mas_equalTo(52*1.5);
- make.height.mas_equalTo(213*1.5);
- }];
- [manBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:25];
-
- [womanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(FITSIZE(-70));
- make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(52));
- make.width.mas_equalTo(52*1.5);
- make.height.mas_equalTo(213*1.5);
- }];
- [womanBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:25];
- }
- - (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
|