1
我試圖自定義我的導航欄,並有2個需要顯示圖標的酒吧按鈕項目。我剛剛在故事板中創建了條形按鈕項目,並將每個圖像設置爲圖標。這些圖標都是正確大小的png(20 x 20pt),但是它們顯示的尺寸比它們應該大得多,因此它們在導航欄上的兩個方向上都顯得很緊張。UIBarButtonItem圖像拉伸,即使使用的圖像是建議的20 x 20點
我正在做故事板中的一切,除了我不得不在viewDidLoad方法中添加一些代碼。我不確定這是否會影響任何效果,但這裏是:
//Make the navigation bar transparent
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
//Setup navigation bar with Avenir Next Regular font and white title color
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"AvenirNext-Regular" size:17], NSFontAttributeName, nil]];
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
我是一個編碼新手,這是我的第一個問題。我會在圖片中發佈以說明問題,但我需要10點聲望才能做到這一點。
在此先感謝您的幫助!
這工作完美。謝謝。我甚至不知道xcassets,所以現在就閱讀它們! – Euka 2014-09-29 04:47:45