2017-04-21 47 views
0

CAKeyframeAnimation不喜歡這樣的:如何讓CAKeyframeAnimation在動畫期間由用戶進行交互?

[UIView animateWithDuration:0.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ 
    .. 
} completion:nil]; 

我們不能成立options:UIViewAnimationOptionAllowUserInteraction。有沒有人有一個好主意,使其在動畫期間與用戶進行交互?

回答

0

我解決了在動畫期間設置定時器更新幀的問題。

//Timer: To update the UI frame 
Timer.scheduledTimer(timeInterval: 0.15, target: self, selector: #selector(updateFrame), userInfo: nil, repeats: true) 

//Timer Selector 
@objc func updateFrame(){ 
    //getting the layer presentation bounds 
    let layer = "button, label...".layer.presentation()! 

    let point = CGPoint(x: layer.frame.origin.x, y: layer.frame.origin.y) 
    let size = CGSize(width: layer.frame.width, height: layer.frame.height) 
    // Update the UI element frame location 
    "ui element".frame = CGRect(origin: point, size: size) 
} 
相關問題