Ну, я думаю, вы должны сгенерировать разные изображения, а затем попытаться анимировать это
imgLoading.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Img1.png"]
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:30.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:60.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:90.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:120.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:150.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:180.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:210.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:240.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:270.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:300.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:330.0]],
[UIImage imageWithCGImage:
[self CGImageRotatedByAngle:
[[UIImage imageNamed:@"Img1.png"] CGImage]angle:360.0]], nil];
imgLoading.animationRepeatCount=0;
imgLoading.animationDuration=.5;
[imgLoading startAnimating];
В приведенном выше коде я добавил изображения отдельно, но вы можете заполнить их в цикле.*
{
CGFloat angleInRadians = angle * (M_PI / 180);
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect imgRect = CGRectMake(0, 0, width, height);
CGAffineTransform transform = CGAffineTransformMakeRotation(angleInRadians);
CGRect rotatedRect = CGRectApplyAffineTransform(imgRect, transform);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef bmContext = CGBitmapContextCreate(NULL,
rotatedRect.size.width,
rotatedRect.size.height,
8,
0,
colorSpace,
kCGImageAlphaPremultipliedFirst);
CGContextSetAllowsAntialiasing(bmContext, YES);
CGContextSetShouldAntialias(bmContext, YES);
CGContextSetInterpolationQuality(bmContext, kCGInterpolationHigh);
CGColorSpaceRelease(colorSpace);
CGContextTranslateCTM(bmContext,
+(rotatedRect.size.width/2),
+(rotatedRect.size.height/2));
CGContextRotateCTM(bmContext, angleInRadians);
CGContextTranslateCTM(bmContext,
-(rotatedRect.size.width/2),
-(rotatedRect.size.height/2));
CGContextDrawImage(bmContext, CGRectMake(0, 0,
rotatedRect.size.width,
rotatedRect.size.height),
imgRef);
CGImageRef rotatedImage = CGBitmapContextCreateImage(bmContext);
CFRelease(bmContext);
[(id)rotatedImage autorelease];
return rotatedImage;
}
Функция «Выше» может использоваться для получения повернутых изображений ..