What kind of toolbars are these at the top and bottom of the view?
How are these added in the code rather than in IB?
The top portion looks like a UINavigationController
presented modally from another UIViewController
. The cancel button is added in the
- (void)viewDidLoad
method of the view as the right navigation item.
The bottom is just a plain old UIToolBar
with 4 buttons.
All UINavigationControllers
have a UIToolbar
built in and it's just a matter of calling the following function to display it.
[self.navigationController setToolbarHidden:NO];
If you want to create buttons, you can call...
- (void)setToolbarItems:(NSArray *)toolbarItems animated:(BOOL)animated
to configure UIToolbar
items. All the items in a UIToolbar
are just an NSArray
of objects. In this case your objects are buttons. In order to properly space the items in the UIToolbar
there's a flexible space object that you can put between your buttons to make it look pretty. So when you setup your array of toolbar items you'd have. Button | Space | Button | Space | Button | Space | Button to accomplish the above look.
Here's some info on the UIToolbar Class Reference if you get lost.
精彩评论