如何为需要下拉的UIview创建动画?

时间:2014-02-27 05:23:21

标签: ios objective-c uiviewanimation uiviewanimationtransition

我想创建一个屏幕,从下拉起,需要下拉。就像iOS通知屏幕(但反方向)。如果有任何示例,请分享。谢谢。

2 个答案:

答案 0 :(得分:2)

在iOS 7中完成此操作的完整方法是使用交互式自定义转换。您将使用UIScreenEdgePanGestureRecognizer并通过执行部分过渡动画来匹配用户手指行进的距离来响应屏幕边缘的拖动手势。查看UIPercentDrivenInteractiveTransition类以帮助您完成此任务。

以下是一个可以下载和运行的完整示例:它是从左侧或右侧进行的,而不是顶部或底部,但它是相同的基本概念。

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

但要注意:如果您尝试从顶部或底部进行操作,您将受到通知中心(顶部)和控制中心(底部)的干扰。防止这种干扰可能很棘手。

答案 1 :(得分:0)

嗨,你可以使用它。

- (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

由于