123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- #import "TASCell.h"
- @implementation TASCell
- - (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
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- UILabel* label;
- label = [UILabel new];
- [self addSubview:label];
- titState = label;
- label = [UILabel new];
- [self addSubview:label];
- lblState = label;
-
- [self.textLabel setFont:[UIFont scaleSize:Font18]];
- [self.detailTextLabel setFont:[UIFont scaleSize:Font18]];
- [lblState setFont:[UIFont scaleSize:Font18]];
- [titState setFont:[UIFont scaleSize:Font18]];
-
- [self.textLabel setTextColor:contentTextColor];
- [self.detailTextLabel setTextColor:contentTextColor];
- [lblState setTextColor:contentTextColor];
- [titState setTextColor:contentTextColor];
-
- }
- return self;
- }
- +(id)cellForTabelView:(UITableView *)tableView
- {
- id cell = [tableView dequeueReusableCellWithIdentifier:@"TASCell"];
- if (!cell) {
- cell = [[TASCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"TASCell"];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- }
- return cell;
- }
- -(void)setModel:(NSDictionary*)obj andSubject:(NSInteger)sub
- {
- if (!obj) {
- return;
- }
-
- subject = sub;
- NSArray* arr = @[@"001.png",@"TASimg1.png",@"TASimg2.png",@"TASimg3.png"];
- [self.imageView imageName:arr[sub]];
- NSString* min,*scroe,*state;
- if (1 == sub) {
- min = obj[@"oneTime"];
- scroe = obj[@"oneScore"];
- state = obj[@"oneStatus"];
- }
- if (2 == sub) {
- min = obj[@"twoTime"];
- scroe = obj[@"twoScore"];
- state = obj[@"twoStatus"];
- }
- if (3 == sub) {
- min = obj[@"threeTime"];
- scroe = obj[@"threeScore"];
- state = obj[@"threeStatus"];
- }
- if (!scroe || [scroe isEqualToString:@""]) {
- scroe = @"暂无";
- }
- [self.textLabel setText:[@"完成学时:" stringByAppendingString:min.hourAndmm]];
- [self.detailTextLabel setText:[@"科目成绩:" stringByAppendingString:scroe]];
- [titState setText:@"科目状态:"];
- [lblState setText:state];
- if ([state isEqualToString:@"通过"]) {
- [lblState setTextColor:defGreen];
- }else{
- [lblState setTextColor:contentTextColor];
- }
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- CGFloat wid = self.width;
- CGFloat hei = self.height;
-
- CGFloat x,y,w,h;
- x = 20;
- w = h = hei*.5;
- y = hei*.25;
- [self.imageView setFrame:CGRectMake(x, y, w, h)];
-
- x +=w + 10;
- w = wid - x;
- h = hei*.5;
- y = 0;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
- h = hei;
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
-
- h = y = hei*.5;
- [titState setFrame:CGRectMake(x, y, w, h)];
- titState.width = [titState.text sizeForFont:Font18].width;
-
- x += titState.width;
- [lblState setFrame:CGRectMake(x, y, w, h)];
- }
- @end
- //废弃
- CGFloat TASCellHeight()
- {
- return 150;
- }
|