Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIToolbar goes under status bar in iOS7

I have a UIView and I have a UIToolbar and UIWebView. I want to show toolbar at top of UIView and after that the rest of page covered with webView. But toolbar goes under status bar like this enter image description here

How can I correct it in iOS7.

like image 622
aakpro Avatar asked Dec 07 '13 13:12

aakpro


3 Answers

1) Set the toolbar Y position to 20 (in the interface builder or in the code)

2) Set the toolbar delegate

3) In your toolbar delegate implement:

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar
{
    return UIBarPositionTopAttached;
} 

enter image description here

like image 84
sash Avatar answered Oct 15 '22 14:10

sash


Set up toolbar delegate to your view controller and implement method:

- (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
    return UIBarPositionTopAttached;
}
like image 6
Greg Avatar answered Oct 15 '22 16:10

Greg


The only correct solution in 2k17 is to attach your toolbar/navigationBar to leading/trailing of your superview, top to topLayoutGuideBottom and to implement positionForBar:. This will produce correct result on all devices.

like image 1
Timur Bernikovich Avatar answered Oct 15 '22 14:10

Timur Bernikovich