Search code examples
iphoneipadfade

How to make controls fade away on iPad/iPhone as per interface guidelines


THe HIG makes a statement that on the iPad, to consider fading away controls similar to how the built in photo app does it. How is this accomplished? In my case I have an image occupying the majority of the screen with a tab bar and potentially tool bar and potentially other controls. How do I fade everything away except the image. And bring it back if the user touches the screen.

Thanks


Solution

  • I think you have 2 alternatives. First, by core animation, you can set the alpha to 0 in about 0.5 or 1 second, the other way is to set the toolbar and navigation bar to hidden. If you're working with a navigation controller, you can call

    [self.navigationController setToolbarHidden:YES animated:YES];
    

    or

    [self.navigationController setNavigationBarHidden:YES animated:YES];
    

    this probably do what you want.

    "And bring it back if the user touches the screen."

    For this, you may implement methods like:

    – touchesBegan:withEvent:
    – touchesMoved:withEvent:
    – touchesEnded:withEvent:
    – touchesCancelled:withEvent:
    

    this will work if you're working on a UIViewController subclass only.