Need tips on adding AutoLayout UIView programmatically with Safe Area

I have a UIView that i create with a XIB. I then want to add it on top of a parent, take up the whole screen but use the safe area i have set up constraints for in the xib.

I can add the view fine, but when i do, the safe area is ignored, and the view goes all the way to the top and bottom.

The code i use (objective-c still sorry):
Code Block
(UIView *parent)
MyViewController *newViewController = [[MyViewController alloc] initWithNibName:MY_VIEW_NIB_NAME bundle:nil];
[view setFrame:CGRectMake(0, 0, parent.bounds.size.width, parent.bounds.size.height)];
[parent addSubview:self.view];

In the Xib, i have the top and bottom constrained to SafeArea.top and bottom. It looks fine in the layout there.


Any tips are appreciated.

I have a UIView that i create with a XIB. I then want to add it on top of a parent, take up the whole screen but use the safe area i have set up constraints for in the xib. 

I'm not sure I fully understand.

Did you set constraint inside the UIView xib relative to safe area ?
How did you do it ?

I would do differently: don't have constraints inside the xib relative to Safe area
Set constraints in code for UIView relative to Safe area by creating constraints programmatically.
Need tips on adding AutoLayout UIView programmatically with Safe Area
 
 
Q