澎湃iPad上线版本

topicBannerLabelCell.m 3.1KB

    // // topicBannerLabelCell.m // ThePaperBase // // Created by liyuan on 15/10/28. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "topicBannerLabelCell.h" @interface topicBannerLabelCell(){ CGFloat descHeight; } @property(nonatomic, strong)UILabel *titleLabel; @property(nonatomic, strong)RTLabel *descLabel; @end @implementation topicBannerLabelCell @synthesize specBO = _specBO; - (void)awakeFromNib { // Initialization code } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.descLabel]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; } return self; } -(void)setSpecBO:(specialObjectBO *)bo{ _specBO = bo; self.titleLabel.text = _specBO.name; self.descLabel.text = _specBO.desc; descHeight = returnTextHeightWithRTLabel(self.descLabel.text, 1300/2, self.descLabel.font, self.descLabel.lineSpacing); [self setLayout]; } #pragma mark -- set view -(UILabel *)titleLabel{ if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.font = appFont(33, NO); _titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; _titleLabel.backgroundColor = [UIColor clearColor]; } return _titleLabel; } -(RTLabel *)descLabel{ if (!_descLabel) { _descLabel = [RTLabel new]; _descLabel.font = appFont(18, NO); _descLabel.textColor = [UIColor colorWithHexString:TextBlack]; _descLabel.lineSpacing = 12; _descLabel.lineBreakMode = RTTextLineBreakModeWordWrapping; } return _descLabel; } //-(void) setLayout{ // self.titleLabel.frame = CGRectMake(0, 50, 1300/2, 30); // self.descLabel.frame = CGRectMake(0, CGRectGetMaxY(self.titleLabel.frame)+30, 1300/2, descHeight); //} - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } - (void)statusBarOrientationChange:(NSNotification *)notification{ [self setLayout]; } - (void) setLayout{ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeRight || orientation ==UIInterfaceOrientationLandscapeLeft) { self.titleLabel.frame = CGRectMake(190, 50, 1300/2, 30); self.descLabel.frame = CGRectMake(190, CGRectGetMaxY(self.titleLabel.frame)+30, 1300/2, descHeight); }else { self.titleLabel.frame = CGRectMake(90, 50, 1300/2, 30); self.descLabel.frame = CGRectMake(90, CGRectGetMaxY(self.titleLabel.frame)+30, 1300/2, descHeight); } } @end