-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhotoAnswerView.m
81 lines (67 loc) · 2.04 KB
/
PhotoAnswerView.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
78
79
80
81
//
// PhotoAnswerView.m
// unnamed
//
// Created by Bruce Ng on 2/24/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//
#import "PhotoAnswerView.h"
#import "GRKBarGraphView.h"
#import "UIColor+AppColor.h"
#import "ParseClient.h"
@interface PhotoAnswerView()
@property (strong, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UIImageView *photoView;
@property (weak, nonatomic) IBOutlet GRKBarGraphView *barView;
@property (nonatomic, strong) Answer *answer;
@property (nonatomic, assign) NSInteger totalVotes;
@end
@implementation PhotoAnswerView
- (void)setup {
UINib *nib = [UINib nibWithNibName:@"PhotoAnswerView" 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 GKBarGraphView
self.barView.barStyle = GRKBarStyleFromRight;
self.barView.barColor = [UIColor appTintColor];
self.barView.tintColor = [UIColor appTintColor];
self.contentView.frame = self.bounds;
[self addSubview:self.contentView];
}
- (id)init {
self = [super init];
if (self) {
[self setup];
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
- (void)setAnswer:(Answer *)answer andTotalVotes:(NSInteger)total {
_answer = answer;
_totalVotes = total;
[ParseClient setImageView:self.photoView fromAnswer:self.answer];
float percent = total > 0 ? (float)answer.count / (float)total : 0;
self.barView.percent = percent;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end