YOUPAIZYSelectSexWindow.m 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // YOUPAIZYSelectSexWindow.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2020/12/14.
  6. // Copyright © 2020 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYSelectSexWindow.h"
  9. #import "UIViewController+TFPresent.h"
  10. @interface YOUPAIZYSelectSexWindow ()
  11. @end
  12. @implementation YOUPAIZYSelectSexWindow
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // [self.view setFrame:CGRectMake(0, 0, _vWith, _vHeight)];
  16. // CAShapeLayer *maskLayer = [CAShapeLayer layer];
  17. // UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.view.bounds cornerRadius:16];
  18. // maskLayer.path = path.CGPath;
  19. // self.view.layer.mask = maskLayer;
  20. // [self.view setBackgroundColor:[UIColor whiteColor]];
  21. NSArray *btnimgArr_n = @[@"vqu_images_D_dynamic_girl_n",@"vqu_images_D_dynamic_boy_n"];
  22. NSArray *btnimgArr_s= @[@"vqu_images_D_dynamic_girl_s",@"vqu_images_D_dynamic_boy_s"];
  23. NSArray *btntitleArr = @[@"女生",@"男生"];
  24. for (int i = 0; i< 2; i++) {
  25. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  26. button.frame = CGRectMake((self.vWidth-55*3)/2.0+(55+55)*i,20,55,75);
  27. [button setTitle:btntitleArr[i] forState:0];
  28. button.titleLabel.font = LCFont(12);
  29. [button setTitleColor:HexColorFromRGB(0x666666) forState:0];
  30. [button setImage:[UIImage imageNamed:btnimgArr_n[i]] forState:UIControlStateNormal];
  31. [button setImage:[UIImage imageNamed:btnimgArr_s[i]] forState:UIControlStateSelected];
  32. button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
  33. [button setTitleEdgeInsets:UIEdgeInsetsMake(button.imageView.frame.size.height +10,-button.imageView.frame.size.width, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变
  34. [button setImageEdgeInsets:UIEdgeInsetsMake(-20, 0.0,0.0, -button.titleLabel.bounds.size.width-10)];//图片距离右边框距离减少图片的宽度,其它不边
  35. [button addTarget:self action:@selector(youpaifselectGenderAction:) forControlEvents:UIControlEventTouchUpInside];
  36. [self.baseView addSubview:button];
  37. button.selected = NO;
  38. button.tag = i+1;
  39. if (i+1 == self.youpaipgender) {
  40. button.selected = YES;
  41. }
  42. }
  43. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  44. button.frame = CGRectMake((self.vWidth - 95)/2.0,116,95,35);
  45. button.layer.cornerRadius = 17.5;
  46. button.layer.masksToBounds = YES;
  47. [button setTitle:@"确定" forState:0];
  48. button.titleLabel.font = LCFont(14);
  49. [button setTitleColor:HexColorFromRGB(0xFFFFFF) forState:0];
  50. // [button setBackgroundImage:[LCTools ColorImage:button.frame.size FromColors:@[ZYGradientOneColor,ZYGradientTwoColor] ByGradientType:(GradientLeftToRight)] forState:(UIControlStateNormal)];
  51. [button setBackgroundColor:HexColorFromRGB(0xA7A9FD)];
  52. [button addTarget:self action:@selector(youpaifsureAction) forControlEvents:UIControlEventTouchUpInside];
  53. [self.baseView addSubview:button];
  54. }
  55. -(void)youpaifselectGenderAction:(UIButton *)sender
  56. {
  57. UIButton *button1 = [self.baseView viewWithTag:1];
  58. UIButton *button2 = [self.baseView viewWithTag:2];
  59. button1.selected = NO;
  60. button2.selected = NO;
  61. sender.selected = YES;
  62. self.youpaipgender = sender.tag;
  63. }
  64. -(void)youpaifsureAction{
  65. [self.youpaipdelegate youpaifSelectSexWindowAction:self.youpaipgender];
  66. [self TFDismissViewController];
  67. }
  68. @end