gpt4 book ai didi

ios - navigationController alpha 会重置吗?当应用程序从后台激活时

转载 作者:行者123 更新时间:2023-11-28 22:19:59 25 4
gpt4 key购买 nike

  1. 我在 AUIController 中,navigationController.navigationBar.alpha == 0.500
  2. 我按下了主页按钮。
  3. 我单击了 appIcon 以返回 AUIController。 navigationController.navigationBar.alpha 到 1.000

我该怎么做才能保持 navigationController.navigationBar 的 alpha = 0.5000 ;

我试过了..

AUIController : UIViewController  <...,UINavigationControllerDelegate>

- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {

if (viewController == self) {
//NSLog(@"self");
//self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.000 green:0.000 blue:0.000 alpha:1.000];
self.navigationController.navigationBar.alpha = 0.500;
self.navigationController.navigationBar.translucent = YES;
} else {
self.navigationController.navigationBar.alpha = 1.000;
self.navigationController.navigationBar.translucent = NO;
}
}

但是当应用程序激活时,alpha 0.50 变为 1.00willShowViewController 不会被调用

最佳答案

您可以使用 KVO 来做到这一点。在 viewDidLoadAUIController添加此代码 [self.navigationController.navigationBar addObserver:self forKeyPath:@"alpha" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:(__bridge void *)(self)];

并实现这个功能:

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSLog([change description]);
UIViewController *viewController = (__bridge UIViewController*)context;
if ([viewController isKindOfClass:[AUIViewController class]]) {
if (self.navigationController.navigationBar.alpha == 1) {
self.navigationController.navigationBar.alpha = 0.500;
self.navigationController.navigationBar.translucent = YES;
}
}
}

关于ios - navigationController alpha 会重置吗?当应用程序从后台激活时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20699342/

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