ShoppingCell.m 5.03 KB
Newer Older
zhu's avatar
zhu committed
1 2 3 4 5 6 7 8 9
//
//  ShoppingCell.m
//  Lighting
//
//  Created by mac on 16/5/23.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ShoppingCell.h"
10 11
#define Width 760
#define Height 90
zhu's avatar
zhu committed
12 13 14 15 16 17 18
#define Gap     5
@implementation ShoppingCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
19
        self.value=1;
zhu's avatar
zhu committed
20 21 22 23 24 25 26 27
        [self bulidLayout];
    }
    return self;
}

- (void)bulidLayout
{
//    选中
28
    self.selectedButton=[[UIButton alloc]initWithFrame:CGRectMake(20, 25, Width/12-40, Height-50)];
zhu's avatar
zhu committed
29 30 31 32 33
    [self.selectedButton setBackgroundImage:[UIImage imageNamed:@"box-副本"] forState:UIControlStateNormal];
//    box-副本
    [self.contentView addSubview:self.selectedButton];
    
//   商品图片
34
    self.goodsImageView=[[UIImageView alloc]initWithFrame:CGRectMake(Width/12, 0, 2*Width/12, Height)];
zhu's avatar
zhu committed
35 36 37 38
    self.goodsImageView.image=[UIImage imageNamed:@"05产品库-详情_03"];
    //05产品库-详情_03
     [self.contentView addSubview:self.goodsImageView];
//     商品信息
39
    self.goodsInformationLabe=[[UILabel alloc]initWithFrame:CGRectMake(3*Width/12, 0, 4*Width/12, Height)];
zhu's avatar
zhu committed
40
    self.goodsInformationLabe.text=@"吊灯jkdsfhkdhfkdsh\n2000133434";
41
     self.goodsInformationLabe.textAlignment=NSTextAlignmentCenter;
zhu's avatar
zhu committed
42 43 44
    self.goodsInformationLabe.numberOfLines=0;
     [self.contentView addSubview:self.goodsInformationLabe];
//   吊牌价格
45 46 47
    self.tagsPriceLabe=[[UILabel alloc]initWithFrame:CGRectMake(7*Width/12, 0,2*Width/12, Height)];
    self.tagsPriceLabe.text=@"¥5500";
    self.tagsPriceLabe.textAlignment=NSTextAlignmentCenter;
zhu's avatar
zhu committed
48
     [self.contentView addSubview:self.tagsPriceLabe];
49 50 51 52
////    成交价格
//    self.clinchTextfield=[[UITextField alloc]initWithFrame:CGRectMake(8*Width/15, 0, 2*Width/15, Height)];
//    self.clinchTextfield.text=@"$5500";
//     [self.contentView addSubview:self.clinchTextfield];
zhu's avatar
zhu committed
53
//    数量减
54
    self.reduceButton=[[UIButton alloc]initWithFrame:CGRectMake(9*Width/12, 20, Width/12-5, Height-40)];
zhu's avatar
zhu committed
55
    [self.reduceButton setTitle:@"-" forState:UIControlStateNormal];
56 57
    self.reduceButton.titleLabel.font=[UIFont systemFontOfSize:18];
    self.reduceButton.backgroundColor=RGB(249, 244, 241, 1);
zhu's avatar
zhu committed
58 59
    [self.reduceButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.reduceButton.titleLabel.font= [UIFont systemFontOfSize: 18.0];
60 61
    self.reduceButton.tag=100;
    [self.reduceButton addTarget:self action:@selector(resetVale:) forControlEvents:UIControlEventTouchUpInside];
zhu's avatar
zhu committed
62 63
    [self.contentView addSubview:self.reduceButton];
//    商品数量
64 65 66 67 68 69
    self.goodsNumbersLabe=[[UILabel alloc]initWithFrame:CGRectMake(10*Width/12, 20, Width/12, Height-40)];
    self.goodsNumbersLabe.text=[NSString stringWithFormat:@"%d",self.value];
     self.goodsNumbersLabe.layer.masksToBounds = YES;
    self.goodsNumbersLabe.layer.cornerRadius=5;
    self.goodsNumbersLabe.layer.borderWidth=1;
    self.goodsNumbersLabe.layer.borderColor=[UIColor grayColor].CGColor;
zhu's avatar
zhu committed
70 71 72
    self.goodsNumbersLabe.textAlignment=NSTextAlignmentCenter;
     [self.contentView addSubview:self.goodsNumbersLabe];
//    数量加
73
    self.addButton=[[UIButton alloc]initWithFrame:CGRectMake(11*Width/12+5, 20, Width/12-5, Height-40)];
zhu's avatar
zhu committed
74
    [self.addButton setTitle:@"+" forState:UIControlStateNormal];
75 76
    self.addButton.titleLabel.font=[UIFont systemFontOfSize:18];
    self.addButton.backgroundColor=RGB(249, 244, 241, 1);
zhu's avatar
zhu committed
77 78
    [self.addButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.addButton.titleLabel.font= [UIFont systemFontOfSize: 18.0];
79 80
    self.addButton.tag=200;
    [self.addButton addTarget:self action:@selector(resetVale:) forControlEvents:UIControlEventTouchUpInside];
zhu's avatar
zhu committed
81
    [self.contentView addSubview:self.addButton];
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(15, Height-1, Width-20, 1)];
    lable.backgroundColor=[UIColor grayColor];
    [self.contentView addSubview:lable];
////    产品金额
//    self.productPriceLabe=[[UILabel alloc]initWithFrame:CGRectMake(13*Width/15, 0, 2*Width/15, Height)];
//     self.productPriceLabe.text=@"$5500";
//    self.productPriceLabe.textColor=[UIColor redColor];
//    [self.contentView addSubview:self.productPriceLabe];
}
-(void)resetVale:(UIButton *)sender
{
    switch (sender.tag) {
        case 100://减少
        {
            if (self.value<=1) {
                return;
            }else
            {
                self.value-=1;
            }
            
        }
            
            break;
        case 200://增加
        {
            self.value+=1;
        }
            
            break;
            
        default:
            break;
    }
    self.goodsNumbersLabe.text=[NSString stringWithFormat:@"%d",self.value];
zhu's avatar
zhu committed
117 118 119 120 121 122 123 124 125 126 127 128 129
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end