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

相關文章
相關標籤/搜索