在iOS中,我想創建一個線段對象併爲其開始點和結束點(我可以在Microsoft的WPF中執行此操作)進行動畫處理。iOS中的動畫線段
目前,我創建了一個線段對象作爲一個小CALayer
我拉伸和使用變換旋轉。
+(LayLine*) layLineWithStartPoint:(CGPoint)ptStart andEndPoint:(CGPoint)ptEnd{
LayLine* line = [[LayLine alloc] init];
line.backgroundColor = [UIColor blackColor].CGColor;
line.frame = CGRectMake(0,-1,1,2); // Line 1 pixel long and 2 pixel wide line segment
line.anchorPoint = CGPointMake(0,0);
line.affineTransform = [LayLine affineTransformationForLineSegment:ptStart to:ptEnd];
return line;
}
我可以通過改變其轉換來爲此線段生成動畫。
這個作品是半好的,但並不完美,因爲在動畫過程中,終點並不像我想的那樣沿着直線。因此,我想知道是否有更好的方法來創建可以製作動畫的線段對象?
,你說什麼樣的動畫呢?這兩個點是否在不同的路徑上行進,或者它們是否位於同一條不變的路徑上的不同位置? – Tommy 2013-03-01 21:07:55
@Tommy,我不知道我理解你的問題,但是ptStartA-ptEndA應該移動到ptStartB-ptEndB(線段B可能垂直於線段A)。 – ragnarius 2013-03-01 21:12:40