-
Notifications
You must be signed in to change notification settings - Fork 0
/
SWTextTableCell.m
76 lines (47 loc) · 2.04 KB
/
SWTextTableCell.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
//
// SWTextTableCell.m
// StarWorld
//
// Created by Aaron Baker on 12/12/11.
// Copyright (c) 2011 Inter Media Outdoors. All rights reserved.
//
#import "SWTextTableCell.h"
#import "SWTextTableItem.h"
@implementation SWTextTableCell
///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)identifier {
self = [super initWithStyle:style reuseIdentifier:identifier];
UIImageView *gradientView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell-bg-blue.png"]];
[self setBackgroundView:gradientView];
[gradientView release];
self.textLabel.backgroundColor = [UIColor clearColor];
return self;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)setObject:(id)object {
if (_item != object) {
[super setObject:object];
TTTableTextItem* item = object;
self.textLabel.text = item.text;
//self.textLabel.backgroundColor = TTSTYLEVAR(backgroundTextColor);
self.textLabel.font = [UIFont systemFontOfSize:16];
self.textLabel.textColor = RGBCOLOR(79, 89, 105);
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.textAlignment = UITextAlignmentLeft;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object {
// XXXjoe Compute height based on font sizes
CGSize givenSize;
givenSize.height = 250;
givenSize.width = 270;
CGSize textSize = [((SWTextTableItem *)object).text sizeWithFont:[UIFont systemFontOfSize:16] constrainedToSize:givenSize];
if (textSize.height < 36.0) {
textSize.height = 36.0;
}
//NSLog(@"TEXT SIZE HEIGHT IN Cell: %f",textSize.height);
CGFloat textHeight = textSize.height + 24;
return textHeight;
}
@end