How to hide user uiview not using view?

I have one view, for example shortcuts with some buttons. Now, when I press the shortcut button, a shortcut appears, now I want the user not to touch the view, how can I hide the display of shortcuts after 8 seconds, and also the user will touch the view for up to 8 seconds until it appears.

+5
source share
2 answers

You can use UIView animation and move the view from the screen

[UIView animateWithDuration:0.333f 
                      delay:8.0f 
                    options:UIViewAnimationCurveEaseOut 
                 animations:^(void) {
                      myView.transform = CGAffineTransformMakeTranslation(0,self.view.frame.size.height);
                           }
                 completion:nil];

In this example, I move your view at the bottom of the screen, CGAffineTransformMakeTranslation(x,y)move the frame of your view at the given points x and y

And to move it, well, you get a drift;)

+1
source

- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay + (void)cancelPreviousPerformRequestsWithTarget:(id)aTarget

-(void)showShortcuts
{
    // all the code you need to show your shortcuts view
    ...
    [self perfornSelector:@selector(hideShortcuts) withObject:nil afterDelay:8.0];
}

-(void)hideShortcuts
{
// all the code you need to hide your shortcuts view
...
}

-(void)shortcutPressed:(id) shortcut
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    // code your shortcut is supposed to trigger
    ...
}
0

All Articles