FreeRDP
Loading...
Searching...
No Matches
EditFlagTableViewCell.m
1/*
2 Custom table cell with toggle switch
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11#import "EditFlagTableViewCell.h"
12
13@implementation EditFlagTableViewCell
14
15@synthesize label = _label, toggle = _toggle;
16
17- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
18{
19 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
20 if (self)
21 {
22 // Initialization code
23 }
24 return self;
25}
26
27- (void)setSelected:(BOOL)selected animated:(BOOL)animated
28{
29 [super setSelected:selected animated:animated];
30
31 // Configure the view for the selected state
32}
33
34// set toggle switch layout margin
35- (void)layoutSubviews
36{
37 [super layoutSubviews];
38
39 if (!_toggle)
40 return;
41
42 CGRect bounds = [[self contentView] bounds];
43 UIEdgeInsets margins = [[self contentView] layoutMargins];
44 CGSize sw = [_toggle frame].size;
45
46 [_toggle setFrame:CGRectMake(CGRectGetMaxX(bounds) - margins.right - sw.width,
47 (bounds.size.height - sw.height) / 2.0, sw.width, sw.height)];
48
49 if (_label)
50 {
51 CGRect lf = [_label frame];
52 lf.origin.x = margins.left;
53 lf.origin.y = (bounds.size.height - lf.size.height) / 2.0;
54 lf.size.width = CGRectGetMinX([_toggle frame]) - margins.left - 8.0;
55 [_label setFrame:lf];
56 }
57}
58
59@end