1
我試圖通過在UINavigationItem的titleview的顯示UIToolbar:UIToolbar在UINaviationItem怪異線在頂部
UIBarButtonItem *mapItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"world_icon"]
style:UIBarButtonItemStylePlain
target:self action:@selector(hi)];
UIBarButtonItem *mapItem2 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"world_icon"]
style:UIBarButtonItemStylePlain
target:self action:@selector(hi)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[toolbar setItems:@[mapItem, spaceItem, mapItem2, spaceItem]];
toolbar.backgroundColor = [UIColor clearColor];
toolbar.barStyle = UIBarStyleDefault;
[toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
toolbar.tintColor = [UIColor whiteColor];
self.navigationItem.titleView = toolbar;
但我在工具欄上獲得這個奇怪的黑線:
任何想法是什麼造成這種情況?謝謝!
你關閉了你的模擬器,並重新啓動你的Xcode,仍然面臨同樣的問題? –
添加工具欄的邊框並設置邊框顏色清晰。 –