12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- //
- // OnlyTicketView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/5/24.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "OnlyTicketView.h"
- @implementation OnlyTicketView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- [self initSubView];
- }
- return self;
- }
- - (void)initSubView {
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 1)];
- line.backgroundColor = [UIColor yhGrayColor];
- [self addSubview:line];
-
- UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 0, 22, 22)];
- imgView.image = [UIImage imageNamed:@"switch_ticket"];
- imgView.centerY = self.height/2;
- [self addSubview:imgView];
-
- UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(imgView.right+10, 0, 100, 20)];
- textLabel.text = @"仅显示优惠券商品";
- textLabel.font = [UIFont systemFontOfSize:12];
- textLabel.textColor = [UIColor YHColorWithHex:0x262626];
- textLabel.centerY = imgView.centerY;
- [self addSubview:textLabel];
-
- self.switchBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width-15-34, 0, 34, 18)];
- self.switchBtn.centerY = imgView.centerY;
- [self.switchBtn setImage:[UIImage imageNamed:@"switch_off"] forState:UIControlStateNormal];
- [self.switchBtn setImage:[UIImage imageNamed:@"switch_on"] forState:UIControlStateSelected];
- [self addSubview:self.switchBtn];
-
- UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(0, self.height-1, self.width, 1)];
- line2.backgroundColor = [UIColor yhGrayColor];
- [self addSubview:line2];
- }
- @end
|