gpt4 book ai didi

ios - 导航 Controller 上的自定义后退按钮未出现

转载 作者:搜寻专家 更新时间:2023-11-01 05:50:42 25 4
gpt4 key购买 nike

我正在尝试在 UINavigationController 中使用自定义后退按钮,但没有显示图像。

screenshot

代码如下:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = true
self.navigationController!.view.backgroundColor = UIColor.clearColor()

self.navigationController?.navigationBar.backIndicatorImage = UIImage(named: "Back-50")
self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "Back-50")
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItemStyle.Plain, target: nil, action: nil)

我不确定这段代码出了什么问题。

最佳答案

也许,您应该使用 UIAppearance。

像这样

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[UINavigationBar appearance] setBackIndicatorImage: [UIImage imageNamed:@"icon-back"]];
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage: [UIImage imageNamed:@"icon-back"]];

return YES;
}

swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(named: "")
UINavigationBar.appearance().backIndicatorImage = UIImage(named: "")

return true
}

关于ios - 导航 Controller 上的自定义后退按钮未出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35436675/

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