gpt4 book ai didi

objective-c - UIStatusBarAnimationFade 持续时间

转载 作者:可可西里 更新时间:2023-11-01 06:16:40 27 4
gpt4 key购买 nike

我有一个应用程序,其中有一个使屏幕逐渐变黑的按钮。我也想让状态栏变黑,所以我使用以下代码:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

我可以设置淡入淡出的持续时间吗?如果那不可行,是否可以获取官方的淡入淡出持续时间(例如使用 UIKeyboardAnimationDurationUserInfoKey 获取键盘滑动持续时间)。


好吧,我没有从任何人那里得到任何返回,但我认为我至少应该分享我的技巧。经过一些实验,我确定淡出为 1 秒,淡入为 0.25 秒。

- (IBAction)fadeToBlack:(id)sender
{
UIView *view = [[[UIView alloc] initWithFrame:self.view.window.frame] autorelease];
view.backgroundColor = [UIColor blackColor];
view.alpha = 0.0;
[self.view.window addSubview:view];

// NOTE: Fading the black view at the same rate as the status bar. Duration is just a guess.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
[UIView animateWithDuration:1.0 animations:^{
view.alpha = 1.0;
} completion:^(BOOL finished) {
[view addGestureRecognizer:self.dismissViewGesture];
}];
}

- (void)dismissViewWithGesture:(UIGestureRecognizer *)gesture
{
UIView *view = gesture.view;
[view removeGestureRecognizer:gesture];

// NOTE: Fading the black view at the same rate as the status bar. Duration is just a guess.
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
[UIView animateWithDuration:0.25 animations:^{
view.alpha = 0.0;
} completion:^(BOOL finished) {
[view removeFromSuperview];
}];
}

最佳答案

我有同样的问题,我的值是 0.5 表示隐藏,0.2 表示导航栏和状态栏一起显示。至少对于 iOS 6.1/iOS Simulator,这些值更符合现实。

关于objective-c - UIStatusBarAnimationFade 持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11140945/

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