0
要設置UIToolBar背景圖片我使用下面的代碼。如何設置UIToolBarPosition頂部或底部
UIToolbar *tool=[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100.0)];
[tool setTintColor:[UIColor darkGrayColor]];
UIBarButtonItem *btn=[[UIBarButtonItem alloc] initWithTitle:@"Load" style:UIBarButtonItemStyleBordered target:nil action:nil];
[tool setItems:[NSArray arrayWithObject:btn]];
UIImage *barImage=[[UIImage imageNamed:@"BarBg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(27,0,27,0)];
[tool setBackgroundImage:barImage forToolbarPosition:UIToolbarPositionBottom
barMetrics:UIBarMetricsDefault];
[self.view addSubview:tool];
這顯示了以下輸出
但問題出現在哪裏紫色背景圖片,我已經建立?
如果我改變位置上方則輸出變爲
[tool setBackgroundImage:barImage forToolbarPosition:UIToolbarPositionTop
barMetrics:UIBarMetricsDefault];
這是我所期望的,設置背景圖片時。
所以我沒有任何明確的想法時使用UIToolBarPositionTop或UIToolBarPositionBottom?
我在這裏找不到問題 – Jonesopolis 2013-04-26 15:39:20
@Jonesy請立即檢查 – weber67 2013-04-26 15:45:08