JXselectSexView.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. //
  2. // JXselectSexView.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/6/8.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXselectSexView.h"
  9. @interface JXselectSexView()<UITextViewDelegate>
  10. @property (nonatomic,weak) UIButton *tongYiBtn;
  11. @property (nonatomic,weak) JXselectSexView *show;
  12. @property (nonatomic,weak) UIButton *selectBtn;
  13. @end
  14. @implementation JXselectSexView
  15. -(instancetype)initWithFrame:(CGRect)frame{
  16. if (self=[super initWithFrame:frame]) {
  17. self.userInteractionEnabled=YES;
  18. UIView *backView=[[UIView alloc]init];
  19. backView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.3];
  20. backView.userInteractionEnabled=YES;
  21. [self addSubview:backView];
  22. [backView mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.top.mas_equalTo(0);
  24. make.left.and.right.mas_equalTo(0);
  25. make.bottom.mas_equalTo(0);
  26. }];
  27. [backView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(closeBtn)]];
  28. UIView *whiteShowView=[[UIView alloc]init];
  29. whiteShowView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:1.0];
  30. whiteShowView.layer.cornerRadius=15;
  31. whiteShowView.userInteractionEnabled=YES;
  32. whiteShowView.layer.masksToBounds=YES;
  33. [backView addSubview:whiteShowView];
  34. whiteShowView.frame=CGRectMake(20, (JX_SCREEN_HEIGHT-200)/2, JX_SCREEN_WIDTH-40, 200);
  35. UILabel *titleL=[[UILabel alloc]init];
  36. titleL.font=[UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
  37. titleL.text=@"选择性别";
  38. [whiteShowView addSubview:titleL];
  39. titleL.frame=CGRectMake(20, 15, JX_SCREEN_WIDTH-40, 16);
  40. NSArray *titleS=@[@"男",@"女"];
  41. for (int i=0; i<titleS.count; i++) {
  42. UIButton *tongYiBtn=[[UIButton alloc]init];
  43. tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  44. [tongYiBtn setTitle:titleS[i] forState:UIControlStateNormal];
  45. [tongYiBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal];
  46. [tongYiBtn setImage:[UIImage imageNamed:@"selected_fause"] forState:UIControlStateNormal];
  47. [tongYiBtn setImage:[UIImage imageNamed:@"selected_true"] forState:UIControlStateSelected];
  48. tongYiBtn.tag=i;
  49. [whiteShowView addSubview:tongYiBtn];
  50. tongYiBtn.frame=CGRectMake(20, CGRectGetMaxY(titleL.frame)+20+ i*(44+10), JX_SCREEN_WIDTH-40, 44);
  51. tongYiBtn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
  52. [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside];
  53. if(i==0){
  54. tongYiBtn.selected=YES;
  55. self.selectBtn=tongYiBtn;
  56. }
  57. }
  58. }
  59. return self;
  60. }
  61. -(void)showView{
  62. JXselectSexView *show=[[JXselectSexView alloc]init];
  63. show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7];
  64. show.frame=[UIScreen mainScreen].bounds;
  65. [[UIApplication sharedApplication].keyWindow addSubview:show];
  66. }
  67. +(void)closeView{
  68. }
  69. -(void)dissmisView{
  70. [self removeFromSuperview];
  71. }
  72. - (void)closeBtn{
  73. self.hidden=YES;
  74. }
  75. - (void)tongyiBtn:(UIButton *)sender{
  76. self.selectBtn.selected=NO;
  77. sender.selected=YES;
  78. self.selectBtn=sender;
  79. self.hidden=YES;
  80. if (_selectBtnBlock) {
  81. _selectBtnBlock(sender);
  82. }
  83. //[self removeFromSuperview];
  84. }
  85. @end