口袋优选

OnlyTicketView.m 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // OnlyTicketView.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "OnlyTicketView.h"
  9. @implementation OnlyTicketView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.backgroundColor = [UIColor whiteColor];
  14. [self initSubView];
  15. }
  16. return self;
  17. }
  18. - (void)initSubView {
  19. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 1)];
  20. line.backgroundColor = [UIColor yhGrayColor];
  21. [self addSubview:line];
  22. UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 22, 22)];
  23. imgView.image = [UIImage imageNamed:@"switch_ticket"];
  24. imgView.centerY = self.height/2;
  25. [self addSubview:imgView];
  26. UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgView.right+10, 0, 100, 20)];
  27. textLabel.text = @"仅显示优惠券商品";
  28. textLabel.font = [UIFont systemFontOfSize:12];
  29. textLabel.textColor = [UIColor YHColorWithHex:0x262626];
  30. textLabel.centerY = imgView.centerY;
  31. [self addSubview:textLabel];
  32. self.switchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width-15-34, 0, 34, 18)];
  33. self.switchBtn.centerY = imgView.centerY;
  34. [self.switchBtn setImage:[UIImage imageNamed:@"switch_off"] forState:UIControlStateNormal];
  35. [self.switchBtn setImage:[UIImage imageNamed:@"switch_on"] forState:UIControlStateSelected];
  36. [self addSubview:self.switchBtn];
  37. UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(0, self.height-1, self.width, 1)];
  38. line2.backgroundColor = [UIColor yhGrayColor];
  39. [self addSubview:line2];
  40. }
  41. @end