123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- //
- // PlanCell.m
- // jiaPeiC
- //
- // Created by apple on 15/12/18.
- // Copyright © 2015年 JCZ. All rights reserved.
- //
- #import "PlanCell.h"
- @interface PlanCell()
- @end
- @implementation PlanCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- UILabel* label;UIImageView* iv;UIButton* btn;
- label = [UILabel new];
- [self addSubview:label];
- lblDate = label;
- label = [UILabel new];
- [self addSubview:label];
- lblName = label;
- label = [UILabel new];
- [self addSubview:label];
- lblNum = label;
- label = [UILabel new];
- [self addSubview:label];
- titNum = label;
- label = [UILabel new];
- [self addSubview:label];
- titDate = label;
- label = [UILabel new];
- [self addSubview:label];
- titCount = label;
- label = [UILabel new];
- [self addSubview:label];
- countLabel = label;
-
-
- iv = [UIImageView new];
- [self addSubview:iv];
- imgDate = iv;
- iv = [UIImageView new];
- [self addSubview:iv];
- imgNum = iv;
-
- btn = [UIButton new];
- [self addSubview:btn];
- btnScan = btn;
-
-
- // [imgNum imageName:@"send_time_icon.png"];
- [imgNum setImage:[UIImage imageNamed:@"send_time_icon.png"]];
- [imgDate setImage:[UIImage imageNamed:@"send_people_num_icon.png"]];
- // [imgDate imageName:@"send_people_num_icon.png"];
- [titNum setFont:[UIFont scaleSize:NormalFont]];
- [titDate setFont:[UIFont scaleSize:NormalFont]];
- [self.textLabel setFont:[UIFont scaleSize:NormalFont]];
- [self.detailTextLabel setFont:[UIFont scaleSize:NormalFont]];
- [titCount setFont:[UIFont scaleSize:NormalFont]];
- [countLabel setFont:[UIFont scaleSize:FontTitle]];
- [lblNum setFont:[UIFont scaleSize:FontTitle]];
- [lblDate setFont:[UIFont scaleSize:FontTitle]];
-
- lblDate.numberOfLines = 0;
-
- [btnScan setTitleColor:defGreen forState:UIControlStateNormal];
- }
- return self;
- }
- +(PlanCell*)cellForTabelView:(UITableView*)tableView
- {
- PlanCell* cell = [tableView dequeueReusableCellWithIdentifier:@"PlanCell"];
- if (!cell) {
- cell = [[PlanCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"PlanCell"];
- }
- return cell;
- }
- -(void)setModel:(NSDictionary *)model
- {
- _model = model;
- [self.textLabel setText:model[@"title"]];
- [self.detailTextLabel setText:model[@"content"]];
- [lblName setText:model[@"userName"]];
- [lblNum setText:model[@"num"]];
- [lblDate setText:[NSString stringWithFormat:@"%@\n%@",model[@"taskTime"],model[@"times"]]];
- [countLabel setText:model[@"havNum"]];
-
- [titDate setText:@"预约时间:"];
- [titNum setText:@"可预约人数:"];
- [titCount setText:@"已预约人数:"];
- [btnScan setTitle:@"查看预约" forState:UIControlStateNormal];
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- CGFloat wid = self.width;
- // CGFloat hei = self.height;
- // SetRandomColor(btnScan);
- // SetRandomColor(self.textLabel);
- // SetRandomColor(self.detailTextLabel);
-
-
- CGFloat x,y,w,h,bd;
- bd = 20;
- h = w = 80;
- x = wid - w;
- y = 0;
- [lblName setFrame:CGRectMake(x, y, w, h)];
-
- y = self.height - h;
- w *= 1.3;
- x = wid - w;
- [btnScan setFrame:CGRectMake(x, y, w, h)];
- [btnScan target:self];
-
- y = 0;
- x = bd;
- h = 35;
- w = kSize.width - bd - w;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
-
- y += h-10;
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
-
- y += h ;
- w = h = 40;
- [imgDate setFrame:CGRectMake(x, y, w, h)];
-
- x += w +10;
- w = [titNum.text sizeForFont:NormalFont].width ;
-
- [titNum setFrame:CGRectMake(x, y - 5, w, 25)];
- [titCount setFrame:CGRectMake(x, y + 20, w, 25)];
-
- x += w +10;
- w = 100;
- [lblNum setFrame:CGRectMake(x, y - 3, w, 25)];
- [countLabel setFrame:CGRectMake(x, y + 20, w, 25)];
-
- x = bd;
- y += h ;
- w = h = 40;
- [imgNum setFrame:CGRectMake(x, y, w, h)];
-
- x += w +10;
- w = [titDate.text sizeForFont:NormalFont].width ;
- [titDate setFrame:CGRectMake(x, y - 2, w, h)];
- x += w +10;
- w = 200;
- [lblDate setFrame:CGRectMake(x, y - 5, w, h+20)];
-
-
-
-
- // for (UIView* v in self.subviews) {
- // SetRandomColor(v);
- // }
- }
- -(void)click:(MyBlockType)block
- {
- clkBlock = block;
- }
- -(void)btnClick:(UIButton*)sender
- {
- if (clkBlock) {
- clkBlock(_model);
- }
- }
- -(void)setStyle:(int)style
- {
- _style = style;
- if (1 == style) {
- [btnScan setHidden:YES];
- }
- }
- @end
- CGFloat PlanCellHeight()
- {
- return 150;
- }
|