2016-08-23 6 views
2

設定navigationController UINavigationControllerのナビゲーションコントローラにそのcompletly描画ではない画像を、画像を設定した後、大きさ750×90画像サイズUINavigationBar

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg.png"] forBarMetrics:UIBarMetricsDefault]; 

と画像上の画像を設定する方法。

画像を設定する方法UINavigationControllerバー。他の画像は、ナビゲーションバーでも同じだろう、UIImageResizingModeStretchとにresizingModeを設定します。resizingMode:

答えて

2
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"bg.png"] forBarMetrics:UIBarMetricsDefault]; 
3

この

がresizableImageWithCapInsetsのメソッドを使用してみてください。

UIImage *currentImgae = [[UIImage imageNamed:@"bg.png"] 
            resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeStretch]; 

[self.navigationController.navigationBar setBackgroundImage:currentImgae forBarMetrics:UIBarMetricsDefault]; 

スウィフト

let currentImgae = UIImage(named: "bg.png")!.resizableImageWithCapInsets(UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .Stretch) 
self.navigationController.navigationBar.setBackgroundImage(currentImgae!, forBarMetrics: .Default) 
+0

@kiran - 答えを受け入れます –