|
//
// liveTitleCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/10.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "liveTitleCell.h"
#import "AsyncImageView.h"
#define TABLEWIDTH 1330/2
@interface liveTitleCell()
@property(nonatomic, strong)AsyncImageView *liveImageView;
@property(nonatomic, strong)UILabel *liveLabel;
@property(nonatomic, strong)UIImageView *liveIconView;
@property(nonatomic, strong)UILabel *liveIconLabel;
@property(nonatomic, strong)UIView *lineView;
@end
@implementation liveTitleCell
@synthesize liveInfo = _liveInfo;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self addSubview:self.liveImageView];
[self.contentView addSubview:self.liveLabel];
[self.contentView addSubview:self.liveIconView];
[self.contentView addSubview:self.liveIconLabel];
[self.contentView addSubview:self.lineView];
}
return self;
}
- (UIView*)lineView {
if (!_lineView) {
_lineView = [[UIView alloc]initWithFrame:CGRectZero];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView;
}
- (void)setLiveInfo:(liveInfoBO *)data {
_liveInfo = data;
self.liveLabel.text = data.name;
self.liveImageView.imageUrl = data.pic;
[self layoutSubviews];
}
- (UIImageView*)liveIconView {
if (!_liveIconView) {
_liveIconView = [[UIImageView alloc]initWithFrame:CGRectZero];
_liveIconView.image = Image(@"topicAndLive/liveImg.png");
}
return _liveIconView;
}
- (UILabel*)liveIconLabel {
if (!_liveIconLabel) {
_liveIconLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_liveIconLabel.font = appFont(18, NO);
_liveIconLabel.textColor = [UIColor colorWithHexString:TextBlack];
_liveIconLabel.text = @"直播中";
_liveIconLabel.backgroundColor = [UIColor clearColor];
}
return _liveIconLabel;
}
- (AsyncImageView*)liveImageView {
if (!_liveImageView) {
_liveImageView = [[AsyncImageView alloc]initWithFrame:CGRectZero];
}
return _liveImageView;
}
- (UILabel*)liveLabel {
if (!_liveLabel) {
_liveLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_liveLabel.textAlignment = NSTextAlignmentLeft;
_liveLabel.font = appFont(40, NO);
_liveLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_liveLabel.textColor = [UIColor colorWithHexString:TextBlack];
_liveLabel.backgroundColor = [UIColor clearColor];
}
return _liveLabel;
}
- (void)layoutSubviews {
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
self.liveImageView.frame = CGRectMake(padding, 30, 60, 60);
self.liveLabel.frame = CGRectMake(CGRectGetMaxX(self.liveImageView.frame)+20,
CGRectGetMinY(self.liveImageView.frame),
500,
60);
self.liveIconView.frame = CGRectMake(CGRectGetMaxX(self.liveLabel.frame),
CGRectGetMinY(self.liveImageView.frame),
25/2,
20);
self.liveIconLabel.frame = CGRectMake(CGRectGetMaxX(self.liveIconView.frame)+5,
CGRectGetMinY(self.liveIconView.frame),
112/2,
CGRectGetHeight(self.liveIconView.frame));
self.lineView.frame = CGRectMake(padding, CGRectGetHeight(self.bounds)-1, TABLEWIDTH, 1);
[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
|