iOS开发UINavigation系列三——工具栏UIToolBar

iOS开发UINavigation系列三——工具栏UIToolBar

        iOS中除了UINavinationBar以外,还有工具栏UIToolBar能够供咱们使用,工具栏和导航栏十分相似,只是功能更加简单,工具栏中也有UIBarButtonItem按钮,在前两篇博客中,对导航栏和导航项都进行的讨论,地址以下:数组

UINavigationBar:http://my.oschina.net/u/2340880/blog/527706工具

UINavigationItem:http://my.oschina.net/u/2340880/blog/527781atom

        导航栏通常会出如今视图的头部,与之相对,工具栏通常会出如今视图的的底部,上面能够填充一些按钮,提供给用户一些操做。建立一个工具栏以下:spa

    self.view.backgroundColor = [UIColor grayColor];
    UIToolbar * tool = [[UIToolbar alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-40, 320, 40)];
    [self.view addSubview:tool];

下面是UIToolBar中的一些方法,其中大部分在UINavigationBar中都有涉及,这里只作简单的介绍:.net

//工具栏的风格,和导航栏相似,有黑白两种
@property(nonatomic) UIBarStyle barStyle; 
//设置工具栏上按钮数组
@property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *items; 
//设置工具栏是否透明
@property(nonatomic,assign,getter=isTranslucent) BOOL translucent; 
//设置工具栏按钮
- (void)setItems:(nullable NSArray<UIBarButtonItem *> *)items animated:(BOOL)animated; 
//设置item风格颜色
@property(null_resettable, nonatomic,strong) UIColor *tintColor;
//设置工具栏背景色
@property(nullable, nonatomic,strong) UIColor *barTintColor;
//设置工具栏背景和阴影图案
- (void)setBackgroundImage:(nullable UIImage *)backgroundImage forToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics;
- (nullable UIImage *)backgroundImageForToolbarPosition:(UIBarPosition)topOrBottom barMetrics:(UIBarMetrics)barMetrics;
- (void)setShadowImage:(nullable UIImage *)shadowImage forToolbarPosition:(UIBarPosition)topOrBottom;
- (nullable UIImage *)shadowImageForToolbarPosition:(UIBarPosition)topOrBottom;

 

专一技术,热爱生活,交流技术,也作朋友。code

——珲少 QQ群:203317592blog

相关文章
相关标签/搜索