如何在目标c中弹出Popout整个视图?

问题描述 投票:0回答:1

我在ViewController中有四个视图作为iPad应用程序。每个视图都有一个不同的按钮和图表控制器。我需要在用户点击特定视图时弹出整个视图。我怎样才能实现这一目标呢?

ios objective-c animation uiview page-zoom
1个回答
0
投票

要以正确的方式执行此操作,我建议使用一点动画弹出您的VIEW。 首先在您的.h文件中添加CAAnimationDelegate:

   @interface ViewController : UIViewController <CAAnimationDelegate>

然后在你的.m文件中

   CABasicAnimation *goOut = [CABasicAnimation animationWithKeyPath:@"position"];
   goOut.delegate = self; 
   // Choose animation duration in seconds, 0 if you dont want.
   [goOut setDuration:0.5]; 
   [goOut setRepeatCount:0];
   // You can play with A and B to specify the direction from where your VIEW will leave the screen
   [goOut setToValue:[NSValue valueWithCGPoint:CGPointMake(VIEW.center.x + A, VIEW.center.y + B)]]; 
   [VIEW.layer addAnimation:goOut forKey:@"position"];

最后只需隐藏VIEW即可

    - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
         if (flag) {
              [VIEW setHidden:YES];
         }
    }

现在,如果你想要你的VIEW改变它的框架并获得屏幕大小只是改变

    CABasicAnimation *goOut = [CABasicAnimation animationWithKeyPath:@"position"];
    [goOut setToValue:[NSValue valueWithCGPoint:CGPointMake(VIEW.center.x + A, VIEW.center.y + B)]];
    [VIEW.layer addAnimation:goOut forKey:@"position"];

     CABasicAnimation *goOut = [CABasicAnimation animationWithKeyPath:@"bounds.size"];
     [goOut setToValue: [NSValue valueWithCGSize:CGSizeMake(self.view.frame.size.width,self.view.frame.size.height)]];
     [VIEW.layer addAnimation:goOut forKey:@"bounds.size"];

并且在这种情况下不要隐藏你的VIEW;)

© www.soinside.com 2019 - 2024. All rights reserved.