UINavigationController

NO IMAGE
1 Star2 Stars3 Stars4 Stars5 Stars 給文章打分!
Loading...

NavigationItem

建立系統樣式的UIBarButtonItem

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:nil];
[item setTintColor:[UIColor redColor]]; 設定item文字或圖片的鏤空顏色 

建立標題樣式的UIBarButtonItem

UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"簡訊" style:UIBarButtonItemStyleDone target:self action:nil];
item.enabled = NO; 設定item的點選是否可用

建立圖示樣式的UIBarButtonItem

UIImage *image = [[UIImage imageNamed:@"iconfont-duanxin"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];  // 32x32 顯示原色(粉色)
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStyleDone target:self action:nil];

建立自定義樣式的UIBarButtonItem

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
UIBarButtonItem *item  = [[UIBarButtonItem alloc] initWithCustomView:button];

多個UIBarButtonItem新增到LeftBarButtonItems中

[self.navigationItem setLeftBarButtonItems:@[leftItem1, leftItem2, leftItem3]];

一個UIBarButtonItem新增到RightBarButtonItem中

[self.navigationItem setRightBarButtonItem:rightItem];

相關文章

IOS開發 最新文章