Skip to content

Instantly share code, notes, and snippets.

@thornpig
Created January 21, 2016 02:09
Show Gist options
  • Save thornpig/9d7152a6d91059c1c4b5 to your computer and use it in GitHub Desktop.
Save thornpig/9d7152a6d91059c1c4b5 to your computer and use it in GitHub Desktop.
When using auto layout, retrieving subview frames should be done after frames are determined based on constraints
In UIViewController subclasses
-(void)viewDidLayoutSubviews
{
self.containerView.frame = self.view.bounds;
self.currentVC.view.frame = self.containerView.bounds;
}
In UIView subclasses
-(void)layoutSubviews
{
[super layoutSubviews];
//accessing frame should be done in layout Subviews
self.thumbnailButton.layer.cornerRadius = 0.5 * CGRectGetWidth(self.thumbnailButton.frame);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment