Added a vertical separator to the contact detail fields.

This commit is contained in:
Guillaume BIENKOWSKI 2013-10-07 17:15:36 +02:00
parent bcfd661408
commit 92f00c7784
2 changed files with 33 additions and 11 deletions

View file

@ -23,6 +23,7 @@
@interface UIEditableTableViewCell : UITransparentTVCell {
}
@property (nonatomic, retain) IBOutlet UIView *verticalSep;
@property (nonatomic, retain) IBOutlet UITextField *detailTextField;
@end

View file

@ -22,6 +22,7 @@
@implementation UIEditableTableViewCell
@synthesize detailTextField;
@synthesize verticalSep;
#pragma mark - Lifecycle Functions
@ -30,7 +31,6 @@
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
UIView *parent = [self.detailTextLabel superview];
self.detailTextField = [[UITextField alloc] init];
[self.detailTextField setHidden:TRUE];
[self.detailTextField setClearButtonMode: UITextFieldViewModeWhileEditing];
@ -39,7 +39,13 @@
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont systemFontSize]];
[self.detailTextLabel setFont:font];
[self.detailTextField setFont:font];
[parent addSubview:detailTextField];
[self.contentView addSubview:detailTextField];
// a vertical separator that will come between the text and detailed text
self.verticalSep = [[UIView alloc] initWithFrame:CGRectMake(80, 5, 1, 34)];
verticalSep.backgroundColor = [UIColor lightGrayColor];
[self.verticalSep setHidden:TRUE];
[self.contentView addSubview:verticalSep];
}
return self;
}
@ -53,17 +59,32 @@
#pragma mark - View Functions
- (void)layoutSubviews {
[super layoutSubviews];
[super layoutSubviews];
CGRect fieldframe;
fieldframe.origin.x = 15;
fieldframe.origin.y = 0;
fieldframe.size.height = 44;
if([[self.textLabel text] length] != 0)
fieldframe.origin.x += [self.textLabel frame].size.width + 5;
CGRect detailEditFrame;
detailEditFrame.origin.x = 15;
detailEditFrame.origin.y = 0;
detailEditFrame.size.height = 44;
if([[self.textLabel text] length] != 0) {
detailEditFrame.origin.x += [self.textLabel frame].size.width + 8;
// shrink left text width by 10px
CGRect leftLabelFrame = [self.textLabel frame];
leftLabelFrame.size.width -= 10;
[self.textLabel setFrame:leftLabelFrame];
// place separator between left text and detailed text
CGRect separatorFrame = [self.verticalSep frame];
separatorFrame.origin.x = leftLabelFrame.size.width + leftLabelFrame.origin.x + 5;
[self.verticalSep setFrame:separatorFrame];
[self.verticalSep setHidden:FALSE];
}
// put the detailed text edit view at the correct position
CGRect superframe = [[self.detailTextField superview] frame];
fieldframe.size.width = superframe.size.width - fieldframe.origin.x;
[self.detailTextField setFrame:fieldframe];
detailEditFrame.size.width = superframe.size.width - detailEditFrame.origin.x;
[self.detailTextField setFrame:detailEditFrame];
}