objective c - UIImageView won't animate with UIImages of CGImage -
i have uiimageview trying make animation of set of uiimages created flipping other uiimages. here's code:
turtle = [[uiimageview alloc] initwithframe:cgrectmake(self.view.frame.size.width-200, self.view.frame.size.height - sand.frame.size.height - turtle.frame.size.height - 10 - heightofkeyboard, 100,100)]; [flippedturtlearray addobject:[uiimage imagewithcgimage:[uiimage imagenamed:@"turtle1.png"].cgimage scale:1 orientation:uiimageorientationdownmirrored]]; [flippedturtlearray addobject:[uiimage imagewithcgimage:[uiimage imagenamed:@"turtle2.png"].cgimage scale:1 orientation:uiimageorientationdownmirrored]]; [flippedturtlearray addobject:[uiimage imagewithcgimage:[uiimage imagenamed:@"turtle3.png"].cgimage scale:1 orientation:uiimageorientationdownmirrored]]; [flippedturtlearray addobject:[uiimage imagewithcgimage:[uiimage imagenamed:@"turtle2.png"].cgimage scale:1 orientation:uiimageorientationdownmirrored]]; [self.view addsubview: turtle];
problem is, when try , make animate array of flipped images, shows originals, not flipped ones (i.e., when this):
turtle.animationimages = flippedturtlearray; turtle.animationduration = 0.8f; turtle.animationrepeatcount = 0; [turtle startanimating];
the original non flipped images shown.
now, if however:
turtle.image = [flippedturtlearray objectatindex:1];
the flipped image shown. thought maybe can't animation cgimage, couldn't find else had had same problem. ideas?
thanks,
sam
i @ cglayer property, , transform property of layer.
the transform property animatable, , allow apply arbitrary transform original image without having manage intermediate flipped turtle array.
the transform applied layer’s contents. animatable.
@property catransform3d transform discussion property set identity transform default. transformations apply layer occur relative layer’s anchor point.
availability available in ios 2.0 , later. related sample code oaltouch declared in calayer.h
if have other reasons wanting array, may want render flipped image separate image, , pass array.
similarly if can use ios 7 target, take spritekit, may make whole task simpler.
Comments
Post a Comment