Smith
Smith

Reputation: 379

How to create animation for UIview that needs to pull down to up?

I want to create a screen to pull up from down and need to pull down.like iOS notifications screen (but in reverse direction).Please share if any example is there.Thanks in advance.

Upvotes: 1

Views: 2868

Answers (2)

matt
matt

Reputation: 535202

The full-on way to do this in iOS 7 is with an interactive custom transition. You will use a UIScreenEdgePanGestureRecognizer and respond to the drag gesture from the edge of the screen by performing part of the transition animation to match the distance the user's finger has travelled. Look into the UIPercentDrivenInteractiveTransition class to help you do that.

Here's a complete example you can download and run: it happens that I'm doing it from the left or right, not the top or bottom, but it is the same basic idea.

https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch06p296customAnimation2/ch19p620customAnimation1/AppDelegate.m

But beware: if you try to do it from the top or the bottom you will get interference from the notification center (top) and the control center (bottom). It can be tricky to prevent that interference.

Upvotes: 2

Harunmughal
Harunmughal

Reputation: 367

Hi you can use it.

- (void)showShareView {

    [self.view bringSubviewToFront:self.view_Email];

    [UIView beginAnimations:@"Show"
                    context:nil];
    [UIView setAnimationDuration:0.3F];

    CGRect frame = self.view_Email.frame;

    if (IS_IPHONE5) {
        if(txtFieldActiveFlag==1){
            frame.origin.y = 568-420;
        }else{
            frame.origin.y = 568-220;
        }
    } else {
        frame.origin.y = 480 - 275 - 88;
    }

    self.view_Email.frame = frame;
    [UIView commitAnimations];
}

- (void)hideShareView {

    [UIView beginAnimations:@"Show"
                    context:nil];
    [UIView setAnimationDuration:0.3F];

    CGRect frame = self.view_Email.frame;

    if (IS_IPHONE5) {

        if(txtFieldActiveFlag==2){
            frame.origin.y = 568-220;
        }else{
            frame.origin.y = 568;
        }
    } else {
        frame.origin.y = 480;
    }
    self.view_Email.frame = frame;
    [UIView commitAnimations];
}


//call method from any button action.

 [self showShareView]; //show the view up

 [self hideShareView]; //show the view down

Thanks

Upvotes: 0

Related Questions