in apple's uicatalog example, there snippet wrote position toolbar @ bottom of screen in navigation controller view (in toolbarviewcontroller.m).
code:
// size toolbar , set frame [toolbar sizetofit]; cgfloat toolbarheight = [toolbar frame].size.height; cgrect mainviewbounds = self.view.bounds; [toolbar setframe:cgrectmake(cgrectgetminx(mainviewbounds), cgrectgetminy(mainviewbounds) + cgrectgetheight(mainviewbounds) - (toolbarheight * 2.0) + 2.0, cgrectgetwidth(mainviewbounds), toolbarheight)]; [self.view addsubview:toolbar];
what don't understand why shifting toolbar downwards 2px (the +2.0 part)? makes toolbar 2px shorter normal toolbar. intentional or there missing here?
guys!
well, more curious why subtracting toolbarheight twice.
have changed code , produces same result original (if uncomment "+2" part). , right.
code:
[toolbar sizetofit]; cgfloat toolbarheight = [toolbar frame].size.height; cgrect mainviewbounds = self.view.bounds; cgrect navrect = self.navigationcontroller.isnavigationbarhidden ? cgrectzero : self.navigationcontroller.navigationbar.bounds; cgrect toolrect = cgrectmake(cgrectgetminx(mainviewbounds), cgrectgetminy(mainviewbounds) + cgrectgetheight(mainviewbounds) - (toolbarheight + navrect.size.height) /*+ 2.0*/, cgrectgetwidth(mainviewbounds), toolbarheight); [toolbar setframe:toolrect];
toolbar ends height of 44 @ y=372. parent view @ y=64, status bar plus navigation bar, 20 + 44. so, 372+64 = 436. toolbar start @ y=436 , height of 44 placed @ bottom. 436 + 44 = 480. but, placing 2 pixels below position, @ 438 482.
looks cooler if it's thinner.
in end, actualy strange not reducing main view height of navigation bar. think proper way code of decrease self.view.frame height of navigation bar.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
Comments
Post a Comment