2015-10-14 33 views
1

enter image description here我需要使其中i具有彎曲的貝塞爾樣/ \和我有在它的左邊底部小對象的應用程序,例如一個平面>SWIFT附上圖像bezierPath

使用你的想象力; )

我具有從0.0到1.0並在其上基部我希望把我的平面上的路徑上的值,例如

  • 0.0平面是在路徑的開始:>/\

  • 0.5是在中途:/> \

  • 1.0是底:/>

我知道如何與動畫做到這一點。

CAKeyframeAnimation(keyPath: "position") then .path = bezierPath 

它很容易!

但我不需要動畫!我想在我的viewDidAppear時把這架飛機放在正確的地方。

如何將UIImage粘貼到UIBezierPath並沿着這條曲線移動它?

+0

當涉及到編程的問題,我強烈希望*不*搞清楚什麼人在談論時要使用我的想象,而是問一個合適的問題描述來處理。所以:而不是ASCII,你可以只附加一個或多個圖像,適當地炫耀你的意思? –

+0

確定發佈圖片已更新 –

回答

0

好吧,我發現解決方案 所有你需要的是設置:

let flightAnimation = CAKeyframeAnimation(keyPath: "position") 
    flightAnimation.path = ovalShapeLayer.path 
    flightAnimation.speed = 0 
    flightAnimation.timeOffset = 0.5 // 50% of the path 
    flightAnimation.duration = 1.0