123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- //
- // FKHotSaleCell.m
- // FirstLink
- //
- // Created by ascii on 2017/6/10.
- // Copyright © 2017年 FirstLink. All rights reserved.
- //
- #import "FKHotSaleCell.h"
- @interface FKHotSaleCell ()
- @property (nonatomic, strong) UIView *horizonLine;
- @property (nonatomic, strong) UIButton *buyButton;
- @property (nonatomic, strong) UIView *bottomLine;
- @end
- @implementation FKHotSaleCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- [self setupViews];
- }
- return self;
- }
- #pragma mark - Method
- - (void)setupViews {
- [self.contentView addSubview:self.proImgView];
- [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.contentView);
- make.left.equalTo(self.contentView).offset(12);
- make.size.mas_equalTo(CGSizeMake(112, 112));
- }];
-
- [self.contentView addSubview:self.proTitleLabel];
- [self.proTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.proImgView.mas_top).offset(24);
- make.left.equalTo(self.proImgView.mas_right).offset(10);
- make.right.equalTo(self.contentView).offset(-12);
- }];
-
- [self.contentView addSubview:self.priceLabel];
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.proImgView.mas_centerY).offset(-4);
- make.left.equalTo(self.proTitleLabel);
- }];
-
- [self.contentView addSubview:self.referPriceLabel];
- [self.referPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.priceLabel);
- make.left.equalTo(self.priceLabel.mas_right).offset(10);
- }];
-
- [self.referPriceLabel addSubview:self.horizonLine];
- [self.horizonLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.priceLabel);
- make.left.right.equalTo(self.referPriceLabel);
- make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
- }];
-
- [self.contentView addSubview:self.buyButton];
- [self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.priceLabel.mas_bottom).offset(12);
- make.right.equalTo(self.contentView).offset(-14);
- make.size.mas_equalTo(CGSizeMake(90, 23));
- }];
-
- [self.contentView addSubview:self.supplierImageView];
- [self.supplierImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.proTitleLabel);
- make.centerY.equalTo(self.buyButton);
- make.size.mas_equalTo(CGSizeMake(80, 17));
- }];
-
- [self.contentView addSubview:self.bottomLine];
- [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.equalTo(self.contentView);
- make.height.mas_equalTo(1.0/[UIScreen mainScreen].scale);
- }];
-
- // order label
- [self.contentView addSubview:self.orderImgView];
- [self.orderImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView);
- make.top.equalTo(self.proImgView);
- }];
-
- [self.orderImgView addSubview:self.orderLabel];
- [self.orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.orderImgView).offset(4);
- make.centerY.equalTo(self.orderImgView);
- }];
- }
- #pragma mark - Property
- - (UIImageView *)proImgView {
- if (!_proImgView) {
- _proImgView = [UIImageView new];
- _proImgView.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _proImgView;
- }
- - (UILabel *)proTitleLabel {
- if (!_proTitleLabel) {
- _proTitleLabel = [UILabel new];
- _proTitleLabel.font = [UIFont systemFontOfSize:14];
- _proTitleLabel.textColor = UIColorFromRGB(0x333333);
- _proTitleLabel.numberOfLines = 2;
- }
- return _proTitleLabel;
- }
- - (UILabel *)priceLabel {
- if (!_priceLabel) {
- _priceLabel = [UILabel new];
- _priceLabel.font = [UIFont boldSystemFontOfSize:14];
- _priceLabel.textColor = UIColorFromRGB(0xff5656);
- }
- return _priceLabel;
- }
- - (UILabel *)referPriceLabel {
- if (!_referPriceLabel) {
- _referPriceLabel = [UILabel new];
- _referPriceLabel.font = [UIFont systemFontOfSize:12];
- _referPriceLabel.textColor = UIColorFromRGB(0x999999);
- }
- return _referPriceLabel;
- }
- - (UIView *)horizonLine {
- if (!_horizonLine) {
- _horizonLine = [UIView new];
- _horizonLine.backgroundColor = UIColorFromRGB(0x999999);
- }
- return _horizonLine;
- }
- - (UIButton *)buyButton {
- if (!_buyButton) {
- _buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _buyButton.layer.cornerRadius = 12;
- [_buyButton.titleLabel setFont:[UIFont systemFontOfSize:12]];
- [_buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- _buyButton.userInteractionEnabled = NO;
-
- _buyButton.backgroundColor = UIColorFromRGB(0xff5656);
- [_buyButton setTitle:@"立即抢购" forState:UIControlStateNormal];
- }
- return _buyButton;
- }
- - (UIImageView *)supplierImageView {
- if (!_supplierImageView) {
- _supplierImageView = [[UIImageView alloc] init];
- _supplierImageView.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _supplierImageView;
- }
- - (UIView *)bottomLine {
- if (!_bottomLine) {
- _bottomLine = [UIView new];
- _bottomLine.backgroundColor = UIColorFromRGB(0xf4f4f4);
- }
- return _bottomLine;
- }
- - (UIImageView *)orderImgView {
- if (!_orderImgView) {
- _orderImgView = [UIImageView new];
- _orderImgView.contentMode = UIViewContentModeScaleAspectFit;
- _orderImgView.image = [UIImage imageNamed:@"HotSaleOrderImgBg"];
- }
- return _orderImgView;
- }
- - (UILabel *)orderLabel {
- if (!_orderLabel) {
- _orderLabel = [UILabel new];
- _orderLabel.font = [UIFont boldSystemFontOfSize:13];
- _orderLabel.textColor = UIColorFromRGB(0xffffff);
- }
- return _orderLabel;
- }
- @end
|