猎豆优选

LDGuideView.m 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // LDGuideView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/8.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "LDGuideView.h"
  9. #import "UIButton+ImageTitleStyle.h"
  10. @implementation LDGuideView
  11. - (instancetype)initWithFrame:(CGRect)frame {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor = [UIColor whiteColor];
  15. [self initSubViews];
  16. }
  17. return self;
  18. }
  19. - (void)initSubViews {
  20. // UIImageView *titleIcon = [[UIImageView alloc] init];
  21. // titleIcon.image = [UIImage imageNamed:@"guideTitle"];
  22. // [self addSubview:titleIcon];
  23. UILabel *titleLb = [[UILabel alloc] init];
  24. titleLb.font = [UIFont systemFontOfSize:16];
  25. titleLb.textAlignment = NSTextAlignmentCenter;
  26. titleLb.textColor = [UIColor homeRedColor];
  27. titleLb.text = @"猎豆优选更懂你";
  28. [self addSubview:titleLb];
  29. UILabel *label = [[UILabel alloc] init];
  30. label.text = @"选择性别进入app";
  31. label.textAlignment = NSTextAlignmentCenter;
  32. label.textColor = [UIColor YHColorWithHex:0x999999];
  33. label.font = [UIFont systemFontOfSize:12];
  34. [self addSubview:label];
  35. UIButton *manBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  36. [manBtn setTitle:@"我是帅哥" forState:UIControlStateNormal];
  37. [manBtn setImage:[UIImage imageNamed:@"guide_boy"] forState:UIControlStateNormal];
  38. manBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  39. [manBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
  40. [manBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
  41. manBtn.tag = 1001;
  42. [self addSubview:manBtn];
  43. UIButton *womanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  44. [womanBtn setTitle:@"我是美女" forState:UIControlStateNormal];
  45. [womanBtn setImage:[UIImage imageNamed:@"guide_girl"] forState:UIControlStateNormal];
  46. womanBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  47. [womanBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
  48. [womanBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
  49. womanBtn.tag = 1000;
  50. [self addSubview:womanBtn];
  51. [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.mas_equalTo(FITSIZE(128));
  53. make.width.mas_equalTo(150);
  54. make.height.mas_equalTo(20);
  55. make.centerX.mas_equalTo(self.mas_centerX);
  56. }];
  57. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.mas_equalTo(titleLb.mas_bottom).mas_offset(15);
  59. make.centerX.mas_equalTo(self.mas_centerX);
  60. make.width.mas_equalTo(300);
  61. }];
  62. [manBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.left.mas_equalTo(FITSIZE(70));
  64. make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(77));
  65. make.width.mas_equalTo(80);
  66. make.height.mas_equalTo(120);
  67. }];
  68. [manBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:0];
  69. [womanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.mas_equalTo(FITSIZE(-70));
  71. make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(77));
  72. make.width.mas_equalTo(80);
  73. make.height.mas_equalTo(120);
  74. }];
  75. [womanBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:0];
  76. }
  77. - (void)changeSexAction:(UIButton *)sender {
  78. NSString *sexStr = [NSString stringWithFormat:@"%ld",sender.tag-1000];
  79. [[NSUserDefaults standardUserDefaults] setObject:sexStr forKey:UserSexKey];
  80. [[NSUserDefaults standardUserDefaults] synchronize];
  81. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  82. [UIView animateWithDuration:1.5 animations:^{
  83. self.alpha = 0;
  84. }];
  85. }
  86. @end