// // strongRelateCountsView.m // ThePaperDemo // // Created by scar1900 on 14-9-22. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "strongRelateCountsCell.h" #import "AsyncImageView.h" #import "RegexKitLite.h" @interface strongRelateCountsCell() @property(nonatomic, strong)AsyncImageView *relateImageView; @property(nonatomic, strong)UILabel *destLabel; @property(nonatomic, strong)UIView *videoView; @property(nonatomic, strong)UIView *imageNumView; @property(nonatomic, strong)UIImageView *videoImg; @property(nonatomic, strong)UILabel *videoDurationLabel; @property(nonatomic, strong)UIImageView *imageSetImg; @property(nonatomic, strong)UILabel *imgeSetNumLabel; @end @implementation strongRelateCountsCell @synthesize listdataBO = _listdataBO; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.relateImageView]; [self.contentView addSubview:self.destLabel]; [self.relateImageView addSubview:self.videoView]; [self.relateImageView addSubview:self.imageNumView]; } return self; } - (UIView*)videoView { if (!_videoView) { _videoView = [[UIView alloc]initWithFrame:CGRectZero]; _videoView.backgroundColor = [UIColor colorWithHexString:@"0x203032"]; _videoView.hidden = YES; [_videoView addSubview:self.videoImg]; [_videoView addSubview:self.videoDurationLabel]; } return _videoView; } - (UIImageView*)videoImg { if (!_videoImg) { _videoImg = [[UIImageView alloc]initWithImage:Image(@"detailPage/videoIcon.png")]; } return _videoImg; } - (UILabel*)videoDurationLabel { if (!_videoDurationLabel) { _videoDurationLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _videoDurationLabel.font = appFont(26, NO); _videoDurationLabel.textColor = [UIColor whiteColor]; _videoDurationLabel.backgroundColor = [UIColor clearColor]; _videoDurationLabel.textAlignment = NSTextAlignmentCenter; } return _videoDurationLabel; } - (UIView*)imageNumView { if (!_imageNumView) { _imageNumView = [[UIView alloc]initWithFrame:CGRectZero]; _imageNumView.backgroundColor = [UIColor clearColor]; _imageNumView.hidden = YES; [_imageNumView addSubview:self.imageSetImg]; [_imageNumView addSubview:self.imgeSetNumLabel]; } return _imageNumView; } - (UIImageView*)imageSetImg { if (!_imageSetImg) { _imageSetImg = [[UIImageView alloc]initWithImage:Image(@"detailPage/imageListPrint.png")]; } return _imageSetImg; } - (UILabel*)imgeSetNumLabel { if (!_imgeSetNumLabel) { _imgeSetNumLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _imgeSetNumLabel.font = appFont(26, NO); _imgeSetNumLabel.textColor = [UIColor whiteColor]; _imgeSetNumLabel.backgroundColor = [UIColor clearColor]; _imgeSetNumLabel.textAlignment = NSTextAlignmentCenter; } return _imgeSetNumLabel; } - (AsyncImageView*)relateImageView { if (!_relateImageView) { _relateImageView = [[AsyncImageView alloc]initWithFrame:CGRectZero]; _relateImageView.backgroundColor = [UIColor clearColor]; _relateImageView.hidden = YES; } return _relateImageView; } - (UILabel*)destLabel { if (!_destLabel) { _destLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _destLabel.backgroundColor = [UIColor clearColor]; _destLabel.textAlignment = NSTextAlignmentLeft; _destLabel.textColor = [UIColor colorWithHexString:StrongRelateDesc]; _destLabel.lineBreakMode = NSLineBreakByWordWrapping; } _destLabel.font = appFont(imageDescFontSize, NO); return _destLabel; } - (void)setListdataBO:(listContObjectVO *)dataBO { _listdataBO = dataBO; NSString *url = dataBO.pic; if (url && ![url isEqualToString:@""]) { // if ([url isMatchedByRegex:@"/[0-9]+\\.jpg"]) { // // } self.relateImageView.imageUrl = url; } dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // CGFloat height = heightForString(dataBO.name, appFont(15, NO), 1320/2-CGRectGetMinX(self.relateImageView.frame), NSLineBreakByWordWrapping); CGFloat height = returnTextHeightWithRTLabel(dataBO.name, 1320/2, appFont(15, NO), 5); CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } dispatch_async(dispatch_get_main_queue(), ^{ self.relateImageView.frame = CGRectMake(1320/4-300*1.1+padding, 0, 600*1.1, 250*1.1); // if ([dataBO.watermark intValue] == 1) {//视频 // self.relateImageView.frame = CGRectMake(1320/4-300*1.1+padding, 0, 600*1.1, 340*1.1); // }else { // self.relateImageView.frame = CGRectMake(1320/4-300*1.1+padding, 0, 600*1.1, 250*1.1); // } if (dataBO.watermark) { if ([dataBO.watermark intValue] == 1) { self.videoView.hidden = NO; self.imageNumView.hidden = YES; self.videoDurationLabel.text = dataBO.duration; }else if ([dataBO.watermark intValue] == 2){ self.videoView.hidden = YES; self.imageNumView.hidden = NO; self.imgeSetNumLabel.text = dataBO.imageNum; }else { self.videoView.hidden = YES; self.imageNumView.hidden = YES; } }else { self.videoView.hidden = YES; self.imageNumView.hidden = YES; } self.destLabel.frame = CGRectMake(padding, CGRectGetMaxY(self.relateImageView.bounds)+5, 1320/2, height+3); NSString *name = dataBO.name; if (name && ![name isEqualToString:@""]) { self.destLabel.text = name; } if (self.relateImageView.hidden) { self.relateImageView.hidden = NO; } self.videoView.frame = CGRectMake(CGRectGetWidth(self.relateImageView.bounds)-70*2, CGRectGetHeight(self.relateImageView.bounds)-50, 70*2, 25*2); self.imageNumView.frame = CGRectMake(CGRectGetWidth(self.relateImageView.bounds)-100, CGRectGetHeight(self.relateImageView.bounds)-50, 100, 50); self.videoImg.frame = CGRectMake(10, CGRectGetHeight(self.videoView.frame)/2-29/2, 29, 29); self.videoDurationLabel.frame = CGRectMake(CGRectGetMaxX(self.videoImg.frame), 0, 140-10-29, 50); self.imageSetImg.frame = CGRectMake(0, CGRectGetHeight(self.videoView.frame)/2-33/2, 40, 33); self.imgeSetNumLabel.frame = CGRectMake(CGRectGetMaxX(self.imageSetImg.frame), 0, 60, 50); }); }); } - (void)layoutSubviews { [super layoutSubviews]; } @end