// // FKWantBuyFirstController.m // FirstLink // // Created by 施昌鹏 on 16/8/17. // Copyright © 2016年 FirstLink. All rights reserved. // #import "FKWantBuyEmptyView.h" @interface FKWantBuyEmptyView () @property (nonatomic, strong) UIView *fieldBgView; @property (nonatomic, strong) UIView *leftDivideView; @property (nonatomic, strong) UIView *rightDivideView; @property (nonatomic, strong) UILabel *showLabel; @property (nonatomic, strong) UIImageView *brandImageview; @property (nonatomic, strong) UIImageView *banenrImageView; @end @implementation FKWantBuyEmptyView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self addAllSubviews]; [self addTapGesture]; } return self; } - (void)addTapGesture{ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapGestureClick:)]; [self addGestureRecognizer:tap]; } -(void)addAllSubviews { [self addSubview:self.banenrImageView]; [self addSubview:self.fieldBgView]; [self addSubview:self.buyButton]; [self addSubview:self.leftDivideView]; [self addSubview:self.rightDivideView]; [self addSubview:self.showLabel]; [self addSubview:self.brandImageview]; [self.fieldBgView addSubview:self.textField]; CGFloat banerH = UISCREENWIDTH * 360.0 / 751.0; [self.banenrImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.equalTo(self); make.height.mas_equalTo(banerH); }]; [self.fieldBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(25); make.right.equalTo(self).offset(- 25); make.top.equalTo(self.banenrImageView.mas_bottom).offset(25); make.height.mas_equalTo(40); }]; [self.textField mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.right.equalTo(self.fieldBgView); make.left.equalTo(self.fieldBgView).offset(9); }]; [self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.fieldBgView.mas_bottom).offset(20); make.left.right.equalTo(self.fieldBgView); make.height.mas_equalTo(40); }]; [self.showLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self); make.top.equalTo(self.buyButton.mas_bottom).offset(35); }]; [self.leftDivideView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.showLabel.mas_left).offset(-5); make.centerY.equalTo(self.showLabel); make.height.mas_equalTo(0.5); make.left.equalTo(self.fieldBgView); }]; [self.rightDivideView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.showLabel.mas_right).offset(5); make.centerY.equalTo(self.showLabel); make.height.mas_equalTo(0.5); make.right.equalTo(self.fieldBgView); }]; [self.brandImageview mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.showLabel.mas_bottom).offset(30); make.left.equalTo(self).offset(20); make.right.equalTo(self).offset(-20); }]; } #pragma mark - Action - (void)tapGestureClick:(UIGestureRecognizer *)sender{ [self endEditing:YES]; } #pragma mark - Property -(UIImageView *)banenrImageView { if (_banenrImageView == nil) { _banenrImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"banenr"]]; } return _banenrImageView; } -(UIView *)fieldBgView { if (_fieldBgView == nil) { _fieldBgView = [[UIView alloc] init]; _fieldBgView.backgroundColor = UIColorFromRGB(0xffffff); _fieldBgView.layer.borderWidth = 0.5; _fieldBgView.layer.borderColor = UIColorFromRGB(0x999999).CGColor; _fieldBgView.layer.cornerRadius = 4; } return _fieldBgView; } -(UITextField *)textField { if (_textField == nil) { _textField = [[UITextField alloc] init]; _textField.borderStyle = UITextBorderStyleNone; _textField.placeholder = @"输入海外网站商品链接"; _textField.font = [UIFont systemFontOfSize:14]; _textField.textColor = UIColorFromRGB(0x999999); _textField.clearButtonMode = UITextFieldViewModeAlways; _textField.returnKeyType = UIReturnKeyDone; } return _textField; } -(UIButton *)buyButton { if (_buyButton == nil) { _buyButton = [UIButton buttonWithType:UIButtonTypeCustom]; _buyButton.backgroundColor = UIColorFromRGB(0xf8bf75); _buyButton.titleLabel.font = [UIFont systemFontOfSize:15]; [_buyButton setTitleColor:UIColorFromRGB(0xffffff) forState:UIControlStateNormal]; [_buyButton setTitle:@"我要买" forState:UIControlStateNormal]; _buyButton.layer.cornerRadius = 4; } return _buyButton; } -(UILabel *)showLabel { if (_showLabel == nil) { _showLabel = [[UILabel alloc] init]; _showLabel.font = [UIFont systemFontOfSize:14]; _showLabel.textColor = UIColorFromRGB(0x333333); _showLabel.text = @"支持网站"; } return _showLabel; } -(UIView *)leftDivideView { if (_leftDivideView == nil) { _leftDivideView = [[UIView alloc] init]; _leftDivideView.backgroundColor = UIColorFromRGB(0xe5e5e5); } return _leftDivideView; } -(UIView *)rightDivideView { if (_rightDivideView == nil) { _rightDivideView = [[UIView alloc] init]; _rightDivideView.backgroundColor = UIColorFromRGB(0xe5e5e5); } return _rightDivideView; } -(UIImageView *)brandImageview { if (_brandImageview == nil) { _brandImageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"brand"]]; _brandImageview.contentMode = UIViewContentModeScaleAspectFit; } return _brandImageview; } @end