說下面的場景: 我繪製了一個四邊形形狀,它是UIView的蒙版。我將形狀圖層表示爲maskLayer
。 maskLayer
不對稱地裁剪UIView的底部。如何在UIBezierPath中製作兩行以不同速度動畫
但是接下來我想在動畫中充分展示我的UIView。動畫應該是maskLayer的左側下降到UIView的底部,並且.2秒後,我的maskLayer的右側也下降到了UIView的底部,從而充分揭示了UIView的實體。
我的做法是先下拉左線,然後右鍵一個如下面的代碼:
//this quadrilateral will put down left corner to the bottom of screen
var path2 = UIBezierPath()
path2.moveToPoint(CGPointZero)
path2.addLineToPoint(CGPoint(x: 0, y: frame.height))
path2.addLineToPoint(CGPoint(x: frame.width, y: frame.height/goldRatio/goldRatio))
path2.addLineToPoint(CGPoint(x: frame.width, y: 0))
path2.closePath()
//this rectangle path will put down both corner to the bottom of screen
//thus fix the view to its original shape
var path3 = UIBezierPath()
path3.moveToPoint(CGPointZero)
path3.addLineToPoint(CGPoint(x: 0, y: frame.height))
path3.addLineToPoint(CGPoint(x: frame.width, y: frame.height))
path3.addLineToPoint(CGPoint(x: frame.width, y: 0))
path3.closePath()
我已經花了2小時試圖弄明白無濟於事。請你給我一些關於如何達到這個目的的指示。
的初始狀態是這樣的:
的最終狀態是這樣的:
我真的感謝您的幫助!