澎湃iPad上线版本

liveTopDateCell.m 2.6KB

    // // liveTopDateCell.m // ThePaperHD // // Created by scar1900 on 15/3/10. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "liveTopDateCell.h" @interface liveTopDateCell() @property(nonatomic, strong)UILabel *topIconLabel; @property(nonatomic, strong)UILabel *dateLabel; @end @implementation liveTopDateCell @synthesize dataDic = _dataDic; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.topIconLabel]; [self.contentView addSubview:self.dateLabel]; } return self; } - (void)setDataDic:(NSDictionary *)dic { _dataDic = dic; NSString *date = dic[@"date"]; self.dateLabel.text = date; } - (UILabel*)topIconLabel { if (!_topIconLabel) { _topIconLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _topIconLabel.textAlignment = NSTextAlignmentCenter; _topIconLabel.textColor = [UIColor whiteColor]; _topIconLabel.font = appFont(15, NO); _topIconLabel.text = @"置顶"; _topIconLabel.backgroundColor = [UIColor colorWithHexString:BLUECOLOR]; } return _topIconLabel; } - (UILabel*)dateLabel { if (!_dateLabel) { _dateLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _dateLabel.textAlignment = NSTextAlignmentLeft; _dateLabel.font = appFont(18, NO); _dateLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; _dateLabel.textColor = [UIColor colorWithHexString:BLUECOLOR]; } return _dateLabel; } - (void)layoutSubviews { CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } self.topIconLabel.frame = CGRectMake(padding, 20, 50, 25); self.dateLabel.frame = CGRectMake(CGRectGetMaxX(self.topIconLabel.frame)+127/2, CGRectGetMinY(self.topIconLabel.frame), 350/2, CGRectGetHeight(self.topIconLabel.frame)); [super layoutSubviews]; } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end