123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // FKCirclePublicProcuctCell.m
- // FirstLink
- //
- // Created by ascii on 16/6/8.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCirclePublicProcuctCell.h"
- #import "FKCircleChoiceProductItem.h"
- #import "FLStringHelper.h"
- @interface FKCirclePublicProcuctCell ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIImageView *photoView;
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *priceLabel;
- @property (nonatomic, strong) UILabel *sourceLabel;
- @end
- @implementation FKCirclePublicProcuctCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = [UIColor whiteColor];
-
- [self addAllSubviews];
- }
- return self;
- }
- - (void)configWith:(id)item {
- if ([item isKindOfClass:[FKCircleChoiceProductItem class]]) {
- FKCircleChoiceProductItem *productItem = (FKCircleChoiceProductItem*)item;
-
- [self.photoView sd_setImageWithURL:[NSURL URLWithString:productItem.photoURL]];
- [self.titleLabel setText:productItem.title];
- [self.priceLabel setText:[NSString stringWithFormat:@"¥%.2lf", [FLStringHelper convertFenStringToYuanValue:productItem.price]]];
- }
- }
- #pragma mark - Layout
- - (void)addAllSubviews {
- [self.contentView addSubview:self.bgView];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(10);
- make.centerY.equalTo(self.contentView);
- make.right.equalTo(self.contentView).offset(-20);
- make.height.mas_equalTo(78);
- }];
-
- [self.bgView addSubview:self.photoView];
- [self.photoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.bgView).offset(8);
- make.centerY.equalTo(self.bgView);
- make.size.mas_equalTo(CGSizeMake(54, 54));
- }];
-
- [self.bgView addSubview:self.titleLabel];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.photoView.mas_right).offset(10);
- make.right.equalTo(self.bgView).offset(-10);
- make.top.equalTo(self.bgView).offset(20);
- }];
-
- [self.bgView addSubview:self.priceLabel];
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.titleLabel);
- make.bottom.equalTo(self.bgView).offset(-20);
- }];
-
- // [self.bgView addSubview:self.sourceLabel];
- // [self.sourceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.equalTo(self.priceLabel.mas_right).offset(16);
- // make.right.lessThanOrEqualTo(self.bgView).offset(-20);
- // make.centerY.equalTo(self.priceLabel);
- // }];
-
- [self.contentView addSubview:self.deleteButton];
- [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(0);
- make.top.equalTo(self.contentView).offset(-8);
- make.size.mas_equalTo(CGSizeMake(50, 40));
- }];
- }
- #pragma mark - Method
- + (CGFloat)height {
- return 78;
- }
- #pragma mark - Property
- - (UIButton *)deleteButton {
- if (!_deleteButton) {
- _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _deleteButton.imageEdgeInsets = UIEdgeInsetsMake(-20, 0, 0, -10);
- [_deleteButton setImage:[UIImage imageNamed:@"CircleDeleteIcon"] forState:UIControlStateNormal];
- }
- return _deleteButton;
- }
- - (UIView *)bgView {
- if (!_bgView) {
- _bgView = [UIView new];
- _bgView.backgroundColor = UIColorFromRGB(0xf4f4f4);
- _bgView.layer.cornerRadius = 4;
- }
- return _bgView;
- }
- - (UIImageView *)photoView {
- if (!_photoView) {
- _photoView = [UIImageView new];
- _photoView.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _photoView;
- }
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel new];
- _titleLabel.textColor = UIColorFromRGB(0x333333);
- _titleLabel.font = [UIFont systemFontOfSize:14];
- }
- return _titleLabel;
- }
- - (UILabel *)priceLabel {
- if (!_priceLabel) {
- _priceLabel = [UILabel new];
- _priceLabel.textColor = UIColorFromRGB(0xff6362);
- _priceLabel.font = [UIFont systemFontOfSize:14];
- }
- return _priceLabel;
- }
- - (UILabel *)sourceLabel {
- if (!_sourceLabel) {
- _sourceLabel = [UILabel new];
- _sourceLabel.textColor = UIColorFromRGB(0x999999);
- _sourceLabel.font = [UIFont systemFontOfSize:14];
- }
- return _sourceLabel;
- }
- @end
|