Setting Frame in Present Modal View Controller in iOS 7
I have issue facing frame, when I do present modal view controller.
[super viewDidLoad];
if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone )
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0)
{
imgHeader.frame = CGRectMake(imgHeader.frame.origin.x, imgHeader.frame.origin.y, 320, 44);
imgHeader.image = [UIImage imageNamed:@"header-bg.png"];
btnBack.frame = CGRectMake(20, 5, 38, 34);
}
else
{
imgHeader.frame = CGRectMake(imgHeader.frame.origin.x, imgHeader.frame.origin.y, 320, 64);
imgHeader.image = [UIImage imageNamed:@"header_bgiOS7.png"];
btnBack.frame = CGRectMake(20, 25, 38, 34);
}
viewHeader.frame = imgHeader.frame;
}
I put different images considering status bar for iOS 7 and iOS 6 and want to put bar button item(btnBack) at proper place, but the frame is not setting properly. I am using auto layout.
When using autoLayout, you cannot set the frame. You must modify the constraints themselves by setting the
@property
constant of the constraint itself.