0

上から下へのアニメーションの方向性を作りたいのですUIViewが、2日間試した後、降伏しました

これが私のコードです

- (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を、割り当てられたビューを非表示にするのに十分な負の値に変更します。アニメーションで表示するときは、「y」を変更するだけで同じCGRectMakeパラメータを使用し、画面に表示する位置を指定します。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 に答える