Skip to content

Commit

Permalink
Bugfix for empty leftTitle.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebin committed Sep 20, 2011
1 parent 728b982 commit 8965d52
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions DDExpandableButton/DDExpandableButton.m
Expand Up @@ -169,9 +169,13 @@ - (void)setLeftTitle:(id)leftTitle
{
[leftTitleView removeFromSuperview];
[leftTitleView release];
leftTitleView = nil;

leftTitleView = [[self getViewFrom:leftTitle] retain];
[self addSubview:leftTitleView];
if (leftTitle != nil)
{
leftTitleView = [[self getViewFrom:leftTitle] retain];
[self addSubview:leftTitleView];
}
}

- (void)setButtons:(NSArray *)buttons
Expand All @@ -196,7 +200,7 @@ - (void)updateDisplay
{
// maxHeight update
maxWidth = 0;
maxHeight = [leftTitleView defaultFrameSize].height + verticalPadding * 2.0f;
maxHeight = (leftTitleView != nil)?[leftTitleView defaultFrameSize].height + verticalPadding * 2.0f:0;
for (DDView *v in labels)
{
maxHeight = MAX(maxHeight, [v defaultFrameSize].height + verticalPadding * 2.0f);
Expand All @@ -210,7 +214,9 @@ - (void)updateDisplay
}

cornerAdditionalPadding = roundf(maxHeight/2.2f) - borderWidth - horizontalPadding;
leftWidth = cornerAdditionalPadding + ((leftTitleView != nil)?horizontalPadding:0.0f) + [leftTitleView defaultFrameSize].width + (((innerBorderWidth == 0.0f) && (leftTitleView != nil))?horizontalPadding:0.0f);

leftWidth = cornerAdditionalPadding;
if (leftTitleView != nil) leftWidth += horizontalPadding + [leftTitleView defaultFrameSize].width + ((innerBorderWidth == 0)?horizontalPadding:0);

self.layer.borderWidth = borderWidth;
self.layer.borderColor = borderColor.CGColor;
Expand Down

0 comments on commit 8965d52

Please sign in to comment.