Skip to content

Instantly share code, notes, and snippets.

@carrchr
Created April 1, 2014 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carrchr/9920995 to your computer and use it in GitHub Desktop.
Save carrchr/9920995 to your computer and use it in GitHub Desktop.
UIButton *bottomButton = [UIButton newAutoLayoutView];
[bottomButton setTitle:@"OKAY" forState:UIControlStateNormal];
[bottomButton setTitleColor:[UIColor colorWithHexString:@"#282828"] forState:UIControlStateNormal];
bottomButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:15.0f];
bottomButton.layer.borderWidth = 1.0f;
bottomButton.layer.borderColor = [[UIColor blackColor] CGColor];
self.bottomButton = bottomButton;
[self.overlay addSubview:bottomButton];
- (void)updateConstraints
{
[self.bottomButton autoAlignAxisToSuperviewAxis:ALAxisVertical];
[self.bottomButton autoSetDimension:ALDimensionWidth toSize:BOTTOM_BUTTON_WDTH];
[self.bottomButton autoSetDimension:ALDimensionHeight toSize:BOTTOM_BUTTON_HT];
// this makes button appear offscreen (above its superview)
// [self.bottomButton autoPinEdgeToSuperviewEdge:ALEdgeBottom withOffset: 10.0];
[self.bottomButton autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:self.overlay.bounds.size.height * -1.0 + self.border];
// but using a negative Inset places it correctly in the Superview
@smileyborg
Copy link

Sorry for the delay in getting to this, got tied up with some other stuff.

Anyways, this is hard for me to debug without more context. But this line looks overly complicated:
[self.bottomButton autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:self.overlay.bounds.size.height * -1.0 + self.border];

Can you try just something simple like the below, and see what happens?
[self.bottomButton autoPinEdgeToSuperviewEdge:ALEdgeBottom];

If this is something you can consistently reproduce and have noticed in other cases, it would be very helpful if you could provide a simple runnable project so I can debug it further -- either from scratch, or by modifying an existing project to exhibit this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment