forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTweetLikeUserCCell.m
More file actions
executable file
·57 lines (49 loc) · 1.88 KB
/
Copy pathTweetLikeUserCCell.m
File metadata and controls
executable file
·57 lines (49 loc) · 1.88 KB
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
//
// TweetLikeUserCCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-8-8.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#define kTweetCell_LikeUserCCell_Height 25.0
#import "TweetLikeUserCCell.h"
@interface TweetLikeUserCCell ()
@property (strong, nonatomic) User *curUser;
@property (strong, nonatomic) NSNumber *likes;
@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *likesLabel;
@end
@implementation TweetLikeUserCCell
- (void)configWithUser:(User *)user likesNum:(NSNumber *)likes{
self.curUser = user;
self.likes = likes;
if (!self.imgView) {
self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kTweetCell_LikeUserCCell_Height, kTweetCell_LikeUserCCell_Height)];
[self.imgView doCircleFrame];
[self.contentView addSubview:self.imgView];
}
if (_curUser) {
[self.imgView sd_setImageWithURL:[_curUser.avatar urlImageWithCodePathResizeToView:_imgView] placeholderImage:kPlaceholderMonkeyRoundView(_imgView)];
if (_likesLabel) {
_likesLabel.hidden = YES;
}
}else{
[self.imgView sd_setImageWithURL:nil];
[self.imgView setImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xdadada"]]];
if (!_likesLabel) {
_likesLabel = [[UILabel alloc] initWithFrame:_imgView.frame];
_likesLabel.backgroundColor = [UIColor clearColor];
_likesLabel.textColor = [UIColor whiteColor];
_likesLabel.font = [UIFont systemFontOfSize:15];
_likesLabel.minimumScaleFactor = 0.5;
_likesLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:_likesLabel];
}
_likesLabel.text = [NSString stringWithFormat:@"%d", _likes.intValue];
_likesLabel.hidden = NO;
}
}
- (void)layoutSubviews{
[super layoutSubviews];
}
@end