澎湃iPad上线版本

searchCell.m 2.7KB

    // // searchCell.m // ThePaperHD // // Created by YoungLee on 15/4/14. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "searchCell.h" @interface searchCell() { CGFloat titleHeight; } @property(nonatomic, strong)RTLabel *titleLabel; @property(nonatomic, strong)UILabel *timeLabel; @property(nonatomic, strong)UIView *line; @end @implementation searchCell -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleGray; self.contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.timeLabel]; [self.contentView addSubview:self.line]; } return self; } -(void) setData:(listContObjectVO *)listBO key:(NSArray *)key{ titleHeight = returnTextHeightWithRTLabel(listBO.name, searchPopSize.width-30, appFont(18, NO), 8); __block NSString *name = listBO.name; //bug:3881 [key enumerateObjectsUsingBlock:^(NSString* obj, NSUInteger idx, BOOL *stop) { if ([name isMatchedByRegex:obj]){ name = [name stringByReplacingOccurrencesOfString:obj withString:[NSString stringWithFormat:@"<font color='#00a5eb'>%@</font><N>",obj]]; } }]; self.titleLabel.text = name; self.timeLabel.text = listBO.pubTime; } -(RTLabel *)titleLabel{ if (!_titleLabel) { _titleLabel = [[RTLabel alloc] init]; _titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; _titleLabel.font = appFont(18, NO); _titleLabel.lineSpacing = 8; _titleLabel.backgroundColor = [UIColor clearColor]; _titleLabel.lineBreakMode = RTTextLineBreakModeWordWrapping; } return _titleLabel; } -(UILabel *)timeLabel{ if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.font = appFont(13, NO); _timeLabel.backgroundColor = [UIColor clearColor]; _timeLabel.textColor = [UIColor colorWithHexString:TextGray]; } return _timeLabel; } -(UIView *)line{ if (!_line) { _line = [[UIView alloc] init]; _line.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _line; } - (void)layoutSubviews { [super layoutSubviews]; self.titleLabel.frame = CGRectMake(15, 10,searchPopSize.width-30, titleHeight); self.timeLabel.frame = CGRectMake(15, CGRectGetMaxY(self.titleLabel.frame)+5, searchPopSize.width-30, 20); self.line.frame = CGRectMake(15, CGRectGetMaxY(self.timeLabel.frame), searchPopSize.width-30, 1); } @end