UINavigationController 上视图之间的过渡动​​画有多长?

发布于 2024-12-07 03:09:44 字数 77 浏览 0 评论 0原文

理想情况下,应该有某种包含该值的常量。

我正在实现具有自己的过渡动画的代码,并且我希望这些代码具有与平台过渡动画相同的长度。

Ideally, there would be some kind of constant containing this value.

I'm implementing code that has it's own transition animations, and I'd like those to have the same length as the platform transition animations.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉城 2024-12-14 03:09:44

iOS 7 及更高版本中,您可以通过设置 UINavigationController 委托并使用以下方法获得准确的值:

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {
    NSTimeInterval duration = [viewController.transitionCoordinator transitionDuration];
}  

如果默认持续时间发生变化,这是面向未来的方法。目前它的值为 0.35 秒。

In iOS 7 and later you can have exact value by setting the UINavigationController delegate and using the method:

- (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController
                    animated:(BOOL)animated {
    NSTimeInterval duration = [viewController.transitionCoordinator transitionDuration];
}  

This is future proof method if the defult duration will ever change. At the moment it's value is 0.35 second.

客…行舟 2024-12-14 03:09:44

没有包含该值的常量。但是,使用以下 UINavigationControllerDelegate 方法:

- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    startTime = [[NSDate date] retain];
}

- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSLog(@"Duration %f", [[NSDate date] timeIntervalSinceDate: startTime]);
}

... 我可以看到持续时间约为 0.35 秒

有趣的是,视图的不同部分需要不同的时间才能过渡到位。有关更多详细信息,请参阅这篇精彩的博客文章:

http:// www.iclarified.com/12396/a-closer-look-at-iphone-transition-animations

There's no constant containing this value. However, using the following UINavigationControllerDelegate methods:

- (void) navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    startTime = [[NSDate date] retain];
}

- (void) navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    NSLog(@"Duration %f", [[NSDate date] timeIntervalSinceDate: startTime]);
}

... I can see that the duration is approx 0.35 seconds

Interestingly, different parts of the views take different times to transition into place. See this great blog post for more details:

http://www.iclarified.com/12396/a-closer-look-at-iphone-transition-animations

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文