gpt4 book ai didi

ios - 导航栏是半透明的,但我想要透明

转载 作者:行者123 更新时间:2023-11-29 02:00:05 27 4
gpt4 key购买 nike

我已经遵循了关于如何使我的顶部栏透明的顶级指南,但我能得到的最好的是半透明的。我还试图让按钮变成白色,而不是默认的蓝色。我错过了什么?

@implementation FindAssetLocationMapViewController

- (void) viewWillAppear:(BOOL)animated {
self.edgesForExtendedLayout = UIRectEdgeAll;
self.extendedLayoutIncludesOpaqueBars = true;
[self.navigationController.navigationBar setTranslucent:YES];
self.navigationController.navigationBar.shadowImage = [UIImage new];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.view.backgroundColor = [UIColor redColor];
}

图片如下。我是否也应该截取 FindAssetLocationMapViewController 属性的屏幕截图?澄清一下,导航 Controller 和导航栏属性没有与之关联的类。

Translucent not Transparent - red for clarity

Nav Controller Attributes

Nav Bar Attributes

最佳答案

在您的应用委托(delegate)中尝试此代码,然后删除您拥有的代码:

+ (UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);

// create a 1 by 1 pixel context
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[color setFill];
UIRectFill(rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
}

把这个放在 application:didFinishLaunchingWithOptions:

    //create background images for the navigation bar
UIImage *clear = [AppDelegate imageWithColor:[UIColor clearColor]];

//customize the appearance of UINavigationBar
[[UINavigationBar appearance] setBackgroundImage:clear forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:clear forBarMetrics:UIBarMetricsCompact];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[UIImage new]];

关于ios - 导航栏是半透明的,但我想要透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30470343/

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