-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBPBrightnessEditableTableViewCell.m
More file actions
70 lines (52 loc) · 1.95 KB
/
BPBrightnessEditableTableViewCell.m
File metadata and controls
70 lines (52 loc) · 1.95 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
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// BPBrightnessEditableTableViewCell.m
// Folio
//
// Created by Jon Olson on 7/29/10.
// Copyright 2010 Ballistic Pigeon, LLC. All rights reserved.
//
#import "BPBrightnessEditableTableViewCell.h"
@implementation BPBrightnessEditableTableViewCell
+ (Class)controlClass {
return [UISlider class];
}
#pragma mark -
#pragma mark Construction and deallocation
- (id)init {
return [self initWithReuseIdentifier:nil];
}
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
dimLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
dimLabel.text = @"☀";
dimLabel.font = [UIFont systemFontOfSize:18.0];
dimLabel.textColor = [UIColor colorWithWhite:0.35 alpha:1.0];
dimLabel.textAlignment = UITextAlignmentCenter;
dimLabel.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:dimLabel];
brightLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
brightLabel.text = @"☀";
brightLabel.font = [UIFont systemFontOfSize:24.0];
brightLabel.textColor = [UIColor colorWithWhite:0.35 alpha:1.0];
brightLabel.textAlignment = UITextAlignmentCenter;
brightLabel.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:brightLabel];
}
return self;
}
#pragma mark -
#pragma mark Accessors
- (UISlider *)brightnessSlider {
return (UISlider *)self.control;
}
#pragma mark -
#pragma mark Layout
- (void)layoutSubviews {
[super layoutSubviews];
const CGFloat sunWidth = 30;
CGRect bounds = self.contentView.bounds;
dimLabel.frame = CGRectMake(0, 0, sunWidth, bounds.size.height);
brightLabel.frame = CGRectMake(bounds.size.width - sunWidth, 0, sunWidth, bounds.size.height);
self.control.frame = CGRectMake(sunWidth + 5, 0, bounds.size.width - 2*(sunWidth + 5), bounds.size.height);
}
@end