2 // IASKPSTitleValueSpecifierViewCell.m
3 // http://www.inappsettingskit.com
6 // Luc Vandal, Edovia Inc., http://www.edovia.com
7 // Ortwin Gentz, FutureTap GmbH, http://www.futuretap.com
8 // All rights reserved.
10 // It is appreciated but not required that you give credit to Luc Vandal and Ortwin Gentz,
11 // as the original authors of this code. You can give credit in a blog post, a tweet or on
12 // a info page of your app. Also, the original authors appreciate letting them know if you use this code.
14 // This code is licensed under the BSD license that is available at: http://www.opensource.org/licenses/bsd-license.php
17 #import "IASKPSTitleValueSpecifierViewCell.h"
18 #import "IASKSettingsReader.h"
21 @implementation IASKPSTitleValueSpecifierViewCell
23 - (void)layoutSubviews {
24 // left align the value if the title is empty
25 if (!self.textLabel.text.length) {
26 self.textLabel.text = self.detailTextLabel.text;
27 self.detailTextLabel.text = nil;
28 if ([self.reuseIdentifier isEqualToString:kIASKPSMultiValueSpecifier]) {
29 self.textLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
30 self.textLabel.textColor = self.detailTextLabel.textColor;
33 [super layoutSubviews];
35 CGSize viewSize = [self.textLabel superview].frame.size;
37 // set the left title label frame
38 CGFloat labelWidth = [self.textLabel sizeThatFits:CGSizeZero].width;
39 CGFloat minValueWidth = (self.detailTextLabel.text.length) ? kIASKMinValueWidth + kIASKSpacing : 0;
40 labelWidth = MIN(labelWidth, viewSize.width - minValueWidth - kIASKPaddingLeft -kIASKPaddingRight);
41 CGRect labelFrame = CGRectMake(kIASKPaddingLeft, 0, labelWidth, viewSize.height -2);
42 self.textLabel.frame = labelFrame;
44 // set the right value label frame
45 if (self.detailTextLabel.text.length) {
46 CGRect valueFrame = CGRectMake(kIASKPaddingLeft + labelWidth + kIASKSpacing,
48 viewSize.width - (kIASKPaddingLeft + labelWidth + kIASKSpacing) - kIASKPaddingRight,
50 self.detailTextLabel.frame = valueFrame;