如何从 iPhone 照片应用程序复制动画

发布于 2024-08-18 10:11:00 字数 1642 浏览 3 评论 0原文

我正在构建一个具有图片查看功能的应用程序。我已经将 UIScrollView 野兽摔倒在地(希望发布我的滚动视图知识 RSN),现在正在尝试复制 iPhone 照片应用程序的一些其他视觉效果。具体来说,当查看图像时,我想将控件和栏溶解掉。

我有一个方法可以切换状态栏、导航栏和选项卡栏的可见性,只留下带有图像的滚动视图。滚动视图是全屏的。我有一个计时器,在用户执行某些操作(单击屏幕、查看下一张图像等)后 3 秒触发,并且在timerFired 方法中,我调用我的方法来关闭栏。单击屏幕即可打开栏。这是切换全屏状态的方法。

- (void)setFullScreen:(BOOL)fullScreen {
    // reset the timer
    [myTimer invalidate];
    [myTimer release];
    myTimer = nil;

    // start animation section
    [UIView beginAnimations:nil context:nil];
        // toggle the status bar    
        [[UIApplication sharedApplication] setStatusBarHidden:fullScreen animated:YES];
        [UIView setAnimationDuration:UINavigationControllerHideShowBarDuration];
        CGFloat alpha = fullScreen ? 0.0 : 1.0;
        // change the alpha to either 0 or 1 based on hiding or showing the bars
        self.navigationController.navigationBar.alpha = alpha;
        self.tabBarController.tabBar.alpha = alpha;

    // do the animations!
    [UIView commitAnimations];

    // restart the timer after we show the bars    
    if (!fullScreen) {
        myTimer = [[NSTimer timerWithTimeInterval:3.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO] retain];
        [[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];
    }
}

这基本上是有效的,但是,它看起来不如照片应用程序好。我正在对 alpha 值进行动画处理,因为我相信这看起来更像照片应用程序,而不是使用隐藏的动画方法。我的问题是对状态栏做同样的事情。

我的问题: (1)状态栏有UIView吗? (2)有没有办法改变状态栏的alpha属性? (3)状态栏是在另一个UIWindow中吗? (4)是否有另一种方法可以使用“合法”方法来实现此目的(我需要将此应用程序放入应用程序商店)?

我已经转储了 UIApplication 的 windows 属性,并且只有 1 个窗口,并且我爬取了视图层次结构,并且状态栏没有明显的视图。

有什么想法吗?

I am building an app that has picture viewing capabilities. I have wrestled the UIScrollView beast to the ground (hope to post my scrollview knowledge RSN) and am now trying to duplicate some of the other visual effects of the iPhone photos app. specifically, when viewing an image, I would like to dissolve the controls and bars away.

I have a method that toggles visibility of the status bar, navigation bar, and tab bar, leaving just the scrollview with an image. The scrollview is full screen. I have a timer that fires 3 seconds after the user does something (single taps the screen, views the next image, etc.) and in the timerFired method, I call my method to turn off the bars. a single tap of the screen turns on the bars. here's the method to toggle the full screen state.

- (void)setFullScreen:(BOOL)fullScreen {
    // reset the timer
    [myTimer invalidate];
    [myTimer release];
    myTimer = nil;

    // start animation section
    [UIView beginAnimations:nil context:nil];
        // toggle the status bar    
        [[UIApplication sharedApplication] setStatusBarHidden:fullScreen animated:YES];
        [UIView setAnimationDuration:UINavigationControllerHideShowBarDuration];
        CGFloat alpha = fullScreen ? 0.0 : 1.0;
        // change the alpha to either 0 or 1 based on hiding or showing the bars
        self.navigationController.navigationBar.alpha = alpha;
        self.tabBarController.tabBar.alpha = alpha;

    // do the animations!
    [UIView commitAnimations];

    // restart the timer after we show the bars    
    if (!fullScreen) {
        myTimer = [[NSTimer timerWithTimeInterval:3.0 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO] retain];
        [[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];
    }
}

This basically works, BUT, it doesn't look as good as the photos app. I am animating the alpha values as I believe that this looks more like the photos app instead of the using the hidden with Animation methods available. My problem is doing the same for the status bar.

my questions:
(1) is there a UIView for the the status bar?
(2) is there a way to change the alpha property of the status bar?
(3) is the statusbar in another UIWindow?
(4) is there another way to achieve this using "legal" methods (I need to put this app in the app store)?

I've dumped the windows property of the UIApplication and there was only 1 window and I've crawled the view hierarchy and there was not an obvious view for the status bar.

any ideas?

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

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

发布评论

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

评论(1

画中仙 2024-08-25 10:11:01

状态栏是SpringBoard自己创建的,它是SBStatusBar类(IIRC继承自UIWindow)。应用商店应用程序无法访问它。

The status bar is created by SpringBoard itself, it is of class SBStatusBar (which IIRC inherits from UIWindow). It is not accessible to app store applications.

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