I\'m not talking about the frame property, because from that you can only get the view\'s size in the xib. I\'m talking about when the view is resized because of its constra
I had a similar issue where I needed to add a top and bottom border to a UITableView that resizes based on its constraints setup in the UIStoryboard. I was able to access the updated constraints with - (void)viewDidLayoutSubviews. This is useful so that you do not need to subclass a view and override its layout method.
/*** SET TOP AND BOTTOM BORDERS ON TABLE VIEW ***/
- (void)addBorders
{
CALayer *topBorder = [CALayer layer];
topBorder.frame = CGRectMake(0.0f, self.tableView.frame.origin.y, 320.0f, 0.5f);
topBorder.backgroundColor = [UIColor redColor].CGColor;
CALayer *bottomBorder = [CALayer layer];
bottomBorder.frame = CGRectMake(0.0f, (self.tableView.frame.origin.y + self.tableView.frame.size.height), 320.0f, 0.5f);
bottomBorder.backgroundColor = [UIColor redColor].CGColor;
[self.view.layer addSublayer:topBorder];
[self.view.layer addSublayer:bottomBorder];
}
/*** GET AUTORESIZED FRAME DIMENSIONS ***/
- (void)viewDidLayoutSubviews{
[self addBorders];
}
Without calling the method from the viewDidLayoutSubview method, only the top border is drawn correctly, as the bottom border is somewhere offscreen.