澎湃iPad上线版本

titleAndAuthorCell.m 3.5KB

    // // titleAndAuthorCell.m // ThePaperDemo // // Created by Scar on 14-9-18. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "titleAndAuthorCell.h" @interface titleAndAuthorCell() { CGFloat titleHeight; } @property(nonatomic, strong)UITextView *titleLabel; @end @implementation titleAndAuthorCell @synthesize contentTitle = _contentTitle; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.titleLabel]; [self firstLayoutSub]; } return self; } - (UITextView*)titleLabel { if (!_titleLabel) { _titleLabel = [UITextView new]; _titleLabel.backgroundColor = [UIColor clearColor]; _titleLabel.textAlignment = NSTextAlignmentLeft; [_titleLabel setEditable:NO]; _titleLabel.scrollEnabled = NO; _titleLabel.showsVerticalScrollIndicator = NO; _titleLabel.showsHorizontalScrollIndicator = NO; _titleLabel.font = appFont(76/2, NO); } return _titleLabel; } - (void)setContentTitle:(NSString *)title { _contentTitle = title; // self.titleLabel.text = title; //【需求】支持新闻标题复制(bug:6008) self.titleLabel.attributedText = getLineSpaceAttributedString(title, 10, appFont(76/2, NO)); //【倒退】新闻详情页和私信详情页:夜间模式下新闻详情页的标题和私信内容未做反色(bug:6048) self.titleLabel.textColor = [UIColor colorWithHexString:TextBlack]; [self.titleLabel setNeedsDisplay]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_main_queue(), ^{ titleHeight = heightForAttributeString(getLineSpaceAttributedString(title, 10, appFont(76/2, NO)), 1320/2, appFont(76/2, NO)); [self layoutSubviews]; }); }); } - (void)firstLayoutSub { CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } [self.titleLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).offset(padding); make.width.mas_equalTo(1320/2); make.top.equalTo(self.contentView.top).offset(5); make.bottom.equalTo(self.contentView.bottom).offset(-25); }]; } #pragma mark - layout method - (void)layoutSubviews { CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } // self.titleLabel.frame = CGRectMake(padding, 5, 1320/2, titleHeight); [self.titleLabel remakeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).offset(padding); make.width.mas_equalTo(1320/2); make.top.equalTo(self.contentView.top).offset(5); make.height.mas_equalTo(titleHeight); }]; [super layoutSubviews]; } - (void)awakeFromNib { // Initialization code } @end