1
基本上這是我的代碼,它繪製了一個有4個不同顏色和相等大小的象限的圓。我想要做的是將這個圓順時針和逆時針旋轉,即順時針旋轉,當我觸摸圓並沿順時針方向拖動它,反之亦然。 我已經通過核心圖形做出了圓圈。還有一件事是圓圈必須以高速旋轉,並逐漸減速直到停止。在這方面的任何幫助將不勝感激。 請儘快回覆。如何順時針和逆時針旋轉圓圈?
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
// CGRect mainSquare = self.bounds/2;
CGRect mainSquare = CGRectMake(X_SPACE, Y_SPACE, 220, 200);
CGContextSaveGState(context);
// Create circle path and clip
CGContextAddEllipseInRect(context, mainSquare);
CGContextClip(context);
// Define rects
NSLog(@"helll %f",mainSquare.size.width);
CGRect topLeft = CGRectMake(mainSquare.origin.x, mainSquare.origin.y, (mainSquare.size.width/2) , (mainSquare.size.height/2));
CGRect topRight = CGRectMake((mainSquare.size.width/2) + X_SPACE, mainSquare.origin.y, mainSquare.size.width/2, (mainSquare.size.height/2));
CGRect bottomLeft = CGRectMake(mainSquare.origin.x, (mainSquare.size.height/2) + Y_SPACE, mainSquare.size.width/2, (mainSquare.size.height/2));
CGRect bottomRight = CGRectMake((mainSquare.size.width/2) + X_SPACE, (mainSquare.size.height/2) + Y_SPACE, mainSquare.size.width/2, mainSquare.size.height/2);
// Define colors
CGColorRef topLeftColor = [[UIColor redColor] CGColor];
CGColorRef topRightColor = [[UIColor blueColor] CGColor];
CGColorRef bottomLeftColor = [[UIColor greenColor] CGColor];
CGColorRef bottomRightColor = [[UIColor yellowColor] CGColor];
// Fill rects with colors
CGContextSetFillColorWithColor(context, topLeftColor);
CGContextFillRect(context, topLeft);
CGContextSetFillColorWithColor(context, topRightColor);
CGContextFillRect(context, topRight);
CGContextSetFillColorWithColor(context, bottomLeftColor);
CGContextFillRect(context, bottomLeft);
CGContextSetFillColorWithColor(context, bottomRightColor);
CGContextFillRect(context, bottomRight);
CGContextRestoreGState(context);
}
嗯,至少你在「回覆儘快」之前說「請」,所以沒有粗魯的行爲從我這裏投降。 ;) – John 2010-06-24 22:05:08
嗯,如果它是一個圓圈,你不會注意到一個旋轉的權利? – 2010-06-24 22:05:52
邁克爾,是的,除了裏面的彩色象限。 – John 2010-06-24 22:08:31