-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommentView.m
72 lines (58 loc) · 1.78 KB
/
CommentView.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
//
// CommentView.m
// unnamed
//
// Created by Casing Chu on 2/23/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//
#import "CommentView.h"
#import "User.h"
@interface CommentView ()
@property (strong, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *commentLabel;
@end
@implementation CommentView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
- (void)setup {
UINib *nib = [UINib nibWithNibName:@"CommentView" bundle:nil];
NSArray *objects = [nib instantiateWithOwner:self options:nil];
// NSLog(@"Nib Objects Count: %ld", objects.count);
// NSLog(@"Height: %f, Width: %f", self.containerView.frame.size.height, self.containerView.frame.size.width);
// Setup ContainerView
self.containerView.frame = self.bounds;
[self.containerView setTranslatesAutoresizingMaskIntoConstraints:YES];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:self.containerView];
[self setNeedsLayout];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super initWithCoder:aDecoder])) {
[self setup];
}
return self;
}
- (void)setComment:(Comment *)comment {
_comment = comment;
self.commentLabel.text = comment.text;
self.nameLabel.text = comment.user[@"profile"][@"name"];
}
- (void)layoutSubviews {
[super layoutSubviews];
self.containerView.frame = self.bounds;
}
@end