gpt4 book ai didi

ios - 如何在 UINavigationBar 上设置图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:23:04 25 4
gpt4 key购买 nike

设置 navigationController 一个大小为 750 × 90 Image Size 的图像

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

在将图像设置为导航 Controller 后,它没有在 UINavigationController 上完全绘制图像。

如何在 UINavigationController 栏上设置图像。

最佳答案

试试这个

use the method of resizableImageWithCapInsets:resizingMode: and set the resizingMode to UIImageResizingModeStretch, else the image would still Same in the navigation bar.

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

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

swift

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

关于ios - 如何在 UINavigationBar 上设置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39098389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com