转载

监听动画过程中 CALayer 的属性改变

有时候可能需要追踪某个物体在动画过程中的属性改变,使得另外一个物体进行同步的属性改变,这时候就要用 CALayer 的 presentationLayer() 来获取

var whiteView: UIView!  let displayLink = CADisplayLink(target: self, selector: "displayLinkCallback")  displayLink.addToRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes)  UIView.animateWithDuration(0.25, animations: {    self.whiteView.frame.origin.y += 49.0   }, completion: {_ in    displayLink.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSRunLoopCommonModes)  })  func displayLinkCallback() {     let layer = whiteView.layer.presentationLayer() as! CALayer   println(layer.frame.origin.y ) } 
正文到此结束
Loading...