Iphone - Auto Position UIToolbar

I have an application in which the UIToolBar will always be at the bottom of the screen. Regardless of the orientation of the device.

The toolbar should have the same screen width and always be justified at the bottom.

If the device rotates, the toolbar should accept a new width and continue to align from the bottom.

Is there any way to do this programmatically?

Thanks for any help.

+3
source share
3 answers

-, . , UITabBarController, . Apple Google, .

, UIToolbar , , , :

// I keep this definition in a file called constants.h since I use it a lot
#define SCREEN_FRAME [[UIScreen mainScreen] applicationFrame]

UIToolbar *tb = [[[UIToolbar alloc]init]autorelease];
// this frame will position a toolbar at the bottom of the screen
tb.frame = CGRectMake(0,
            SCREEN_FRAME.size.height-tb.frame.size.height,
            SCREEN_FRAME.size.width, 
            tb.frame.size.height);
//Setting the auto-resizing mask will make the toolbar resize when the viewController 
//it resides in rotates.
tb.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+6

. .

0

Use the navigation controller and use the property toolbarItems.

0
source

Source: https://habr.com/ru/post/1733688/


All Articles