-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathTweetMediaItemCCell.m
executable file
·77 lines (65 loc) · 2.29 KB
/
TweetMediaItemCCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// TweetMediaItemCCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-9-5.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#define kTweetMediaItemCCell_Width ((kScreen_Width - 36.0)/3.0)
#import "TweetMediaItemCCell.h"
@interface TweetMediaItemCCell ()
@end
@implementation TweetMediaItemCCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)setCurMediaItem:(HtmlMediaItem *)curMediaItem{
if (!_imgView) {
_imgView = [[YLImageView alloc] initWithFrame:CGRectMake(0, 0, kTweetMediaItemCCell_Width, kTweetMediaItemCCell_Width)];
_imgView.contentMode = UIViewContentModeScaleAspectFill;
_imgView.clipsToBounds = YES;
// _imgView.layer.masksToBounds = YES;
// _imgView.layer.cornerRadius = 2.0;
[self.contentView addSubview:_imgView];
}
if (_curMediaItem != curMediaItem) {
_curMediaItem = curMediaItem;
[self.imgView sd_setImageWithURL:[_curMediaItem.src urlImageWithCodePathResize:2*kTweetMediaItemCCell_Width crop:YES] placeholderImage:kPlaceholderCodingSquareWidth(80.0) options:SDWebImageRetryFailed];
// gifMark
if ([self.curMediaItem isGif]) {
if (!_gifMarkView) {
_gifMarkView = ({
UIImageView *imgView = [UIImageView new];
imgView.image = [UIImage imageNamed:@"gif_mark"];
[self.imgView addSubview:imgView];
@weakify(self);
[imgView mas_makeConstraints:^(MASConstraintMaker *make) {
@strongify(self);
make.size.mas_equalTo(CGSizeMake(24, 13));
make.right.bottom.equalTo(self.imgView).offset(0);
}];
imgView;
});
}
self.gifMarkView.hidden = NO;
}else{
self.gifMarkView.hidden = YES;
}
}
}
- (void)layoutSubviews{
[super layoutSubviews];
}
+(CGSize)ccellSizeWithObj:(id)obj{
CGSize itemSize = CGSizeZero;
if ([obj isKindOfClass:[HtmlMediaItem class]]) {
itemSize = CGSizeMake(kTweetMediaItemCCell_Width, kTweetMediaItemCCell_Width);
}
return itemSize;
}
@end