簡體   English   中英

經過特定的搜索后如何觸發動畫?

[英]How can I trigger my animation after a specific segue?

我有一個正在播放的動畫。 我按照這個答案Xcode如何上下移動動畫圖像

我能夠通過按鈕觸發動畫。 我真正想要的是在特定的設置之后觸發動畫。 當我選擇情節提要中的特定視圖時,是否可以觸發此動畫?

動畫在ViewController實現中的一個方法中。

-(void)animatePicker
{

    NSLog(@"Animate");
    CGPoint startPoint = (CGPoint){100.f, 100.f};
    CGPoint middlePoint = (CGPoint){400.f, 400.f};
    CGPoint endPoint = (CGPoint){600.f, 100.f};

    CGMutablePathRef thePath = CGPathCreateMutable();
    CGPathMoveToPoint(thePath, NULL, startPoint.x, startPoint.y);
    CGPathAddLineToPoint(thePath, NULL, middlePoint.x, middlePoint.y);
    CGPathAddLineToPoint(thePath, NULL, endPoint.x, endPoint.y);

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.duration = 3.f;
    animation.path = thePath;
    [pickerCircle.layer addAnimation:animation forKey:@"position"];
    pickerCircle.layer.position = endPoint;
}

實現-(void)viewDidAppear; UIViewController中的方法,然后在其中調用動畫函數。

創建並顯示UIViewController視圖后,將調用此函數。

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    NSLog(@"viewDidAppear");
    [masterViewController animate];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM