iOS 10 iMessage app extension: how do i calculate the height of the extra tall navbar iOS 10 iMessage app extension: how do i calculate the height of the extra tall navbar swift swift

iOS 10 iMessage app extension: how do i calculate the height of the extra tall navbar


It may help to have a constraint with the top layout guide like so:

view.topAnchor.constraint(equalTo: self.topLayoutGuide.bottomAnchor).isActive = true


You can get the height from controller's layout guide:

self.topLayoutGuide.length

The reason why @Dilts's demo works is because the labels' top are constraint to the top layout guide. If they are constraint to the superview, then it will also go behind the bar.


If you are like me and still find Auto Layout hard to use, then you can use the viewDidLayoutSubviews method to automatically adjust the view size. I have a table view with the same issue as you, so I used this simple method to change the table view's top side content inset:

-(void)viewDidLayoutSubviews {    [self.tableView setContentInset:UIEdgeInsetsMake(self.topLayoutGuide.length, 0, 0, 0)];}

So far it works fine (in both portrait and landscape) on all iDevices.