省钱达人

DRGuideView.m 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // DRGuideView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/8.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "DRGuideView.h"
  9. #import "UIButton+ImageTitleStyle.h"
  10. @implementation DRGuideView
  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. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
  28. NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
  29. titleLb.text = [NSString stringWithFormat:@"%@更懂你",app_Name];
  30. [self addSubview:titleLb];
  31. UILabel *label = [[UILabel alloc] init];
  32. label.text = @"选择性别进入app";
  33. label.textAlignment = NSTextAlignmentCenter;
  34. label.textColor = [UIColor YHColorWithHex:0x999999];
  35. label.font = [UIFont systemFontOfSize:12];
  36. [self addSubview:label];
  37. UIButton *manBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  38. [manBtn setTitle:@"我是帅哥" forState:UIControlStateNormal];
  39. [manBtn setImage:[UIImage imageNamed:@"guide_boy"] forState:UIControlStateNormal];
  40. manBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(14)];
  41. manBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  42. [manBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
  43. [manBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
  44. manBtn.tag = 1001;
  45. [self addSubview:manBtn];
  46. UIButton *womanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  47. [womanBtn setTitle:@"我是美女" forState:UIControlStateNormal];
  48. [womanBtn setImage:[UIImage imageNamed:@"guide_girl"] forState:UIControlStateNormal];
  49. womanBtn.titleLabel.font = [UIFont systemFontOfSize:Fitsize(14)];
  50. womanBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  51. [womanBtn addTarget:self action:@selector(changeSexAction:) forControlEvents:UIControlEventTouchUpInside];
  52. [womanBtn setTitleColor:[UIColor YHColorWithHex:0x111111] forState:UIControlStateNormal];
  53. womanBtn.tag = 1000;
  54. [self addSubview:womanBtn];
  55. [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.mas_equalTo(FITSIZE(100));
  57. make.width.mas_equalTo(150);
  58. make.height.mas_equalTo(20);
  59. make.centerX.mas_equalTo(self.mas_centerX);
  60. }];
  61. [label mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.mas_equalTo(titleLb.mas_bottom).mas_offset(15);
  63. make.centerX.mas_equalTo(self.mas_centerX);
  64. make.width.mas_equalTo(300);
  65. }];
  66. [manBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.left.mas_equalTo(FITSIZE(70));
  68. make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(52));
  69. make.width.mas_equalTo(52*1.5);
  70. make.height.mas_equalTo(213*1.5);
  71. }];
  72. [manBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:25];
  73. [womanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.right.mas_equalTo(FITSIZE(-70));
  75. make.top.mas_equalTo(label.mas_bottom).mas_offset(FITSIZE(52));
  76. make.width.mas_equalTo(52*1.5);
  77. make.height.mas_equalTo(213*1.5);
  78. }];
  79. [womanBtn setButtonImageTitleStyle:ButtonImageTitleStyleCenterDown padding:25];
  80. }
  81. - (void)changeSexAction:(UIButton *)sender {
  82. NSString *sexStr = [NSString stringWithFormat:@"%ld",sender.tag-1000];
  83. [[NSUserDefaults standardUserDefaults] setObject:sexStr forKey:UserSexKey];
  84. [[NSUserDefaults standardUserDefaults] synchronize];
  85. [[NSNotificationCenter defaultCenter] postNotificationName:ChangeSex object:nil];
  86. [UIView animateWithDuration:1.5 animations:^{
  87. self.alpha = 0;
  88. }];
  89. }
  90. @end