如何使UIView从上到下,反之亦然

时间:2013-03-05 09:20:10

标签: iphone ios

当我们在屏幕顶部拖动并向下拖动时,我正在尝试制作动画,其中UIView应该从上到下(或直到屏幕中间)。

2 个答案:

答案 0 :(得分:1)

设置视图框,然后在按钮操作中添加这些代码,或者。

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationDuration:1.0];
    [yourView setFrame:CGRectMake(0, 250, 320, 100)];
    [UIView commitAnimations];

答案 1 :(得分:0)

根据您的需要设置位置

[UIView beginAnimations:@"DragView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.5f];
self.dragView.frame = CGRectMake(newXPose, newYPose,width, height);
[UIView commitAnimations];  
相关问题