ios – UINavigationController透明度?

ios – UINavigationController透明度?,第1张

概述我试图让我的导航栏变为100%透明,这样UINavigationButtonItems只能看到,背景(通常是白色)应该显示背景图像. 我试过了 HomeNavigationController *navBar = [[HomeNavigationController alloc] initWithRootViewController:self.myViewController];[navBar. 我试图让我的导航栏变为100%透明,这样UINavigationbuttonItems只能看到,背景(通常是白色)应该显示背景图像.

我试过了

HomeNavigationController *navbar = [[HomeNavigationController alloc] initWithRootVIEwController:self.myVIEwController];[navbar.navigationbar setbarTintcolor:[UIcolor clearcolor]];    [navbar.navigationbar setTranslucent:YES];

虽然似乎都不起作用.

编辑:

运用

[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];

我可以看到它按预期工作,但现在这些项目也是看不见的.

FINALEDIT:啊,上面的代码可以工作,只是确保你没有先测试就不对外观进行任何其他改动!

实际执行预期的代码:

[self.navigationController.navigationbar setBackgroundImage:[UIImage new]                                                  forbarMetrics:UIbarMetricsDefault];

或者,您可以设置透明图像,但这更有意义.如果您不想要代表边框的线,则需要原始编辑中显示的其余代码.

解决方法 有一个技巧.
只需将透明图像设置为导航栏背景即可.
UIImage *fakeImage = [UIImage imagenamed:@"transparentImage"];[navigationbar setBackgroundImage:fakeImage forbarMetrics:UIbarMetricsDefault];

要么

[navigationbar setBackgroundImage:[UIImage new]                    forbarMetrics:UIbarMetricsDefault];
总结

以上是内存溢出为你收集整理的ios – UINavigationController透明度?全部内容,希望文章能够帮你解决ios – UINavigationController透明度?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1107687.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存