0

我想UIView从上到下创建动画方向,但是尝试了两天后,我投降了

这是我的代码

- (IBAction)goAction:(id)sender 
{
    primaryView.userInteractionEnabled = NO;

    [UIView animateWithDuration:0.3 animations:^{
        secondaryView.frame = CGRectMake(0, 100, secondaryView.frame.size.width, secondaryView.frame.size.height);

        CALayer *layer = primaryView.layer;
        layer.zPosition = -4000;
        CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
        rotationAndPerspectiveTransform.m21 = 1.0 / -300;
        layer.transform = CATransform3DRotate(rotationAndPerspectiveTransform, 10.0f * M_PI / 180.0f, 1.0f, 0.0f, 0.0f);            
        primaryShadeView.alpha = 0.35;
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 animations:^{
            primaryView.transform = CGAffineTransformMakeScale(0.9,0.9);
            primaryShadeView.alpha = 0.5;
        }];
    }];
}

这个方向......从下到上......希望大家能帮助我:)

4

2 回答 2

1

最初将视图分配在导航栏上方的位置。

CGRectMake(0, 100, secondaryView.frame.size.width, secondaryView.frame.size.height);

这里将值 100 更改为足以隐藏您分配的视图的负值。在显示动画期间,使用相同的 CGRectMake 参数,仅更改“y”,给出在屏幕上显示的位置。在 nNext 单击以相同方式隐藏它。

那有意义吗?

这是示例:

在您的按钮操作中:

{
    if(!youNewView)
    {
        youNewView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width, -220(depends on your view height), 320, 300) ];
      //add additional properties you need to add here
        [self.View addSubview:youNewView];
    }

     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:newView cache:YES];
     [UIView commitAnimations];

else
{
    [UIView animateWithDuration:.5 animations:^{
        newView.frame = CGRectMake(newView.frame.origin.x, -210, myPicker.frame.size.width, newView.frame.size.height);
    } completion:^(BOOL finished) {
        [newView removeFromSuperview];
    }];
}
于 2012-11-01T09:32:13.640 回答
-1
    [UIView animateWithDuration:0.5 animations:^{
    self.view.frame = CGRectMake(self.view.frame.origin.x,
                                              self.view.frame.size.height,
                                              self.view.frame.size.width,
                                              self.view.frame.size.height);
    [self.view layoutIfNeeded];
}];

请试试这个,它对我有用。

于 2015-10-07T09:19:32.727 回答