Reputation: 199
I have a UIImageView that should animate an array of images called capturedImages
. I have the animation set up like so:
imageView = [[UIImageView alloc] init];
imageView.frame = CGRectMake(0, 48, 320, 520);
imageView.animationImages = capturedImages;
imageView.animationDuration = 3.0;
imageView.animationRepeatCount = 0; //animate forever
[imageView startAnimating];
[self.view addSubview:imageView];
The images in capturedImages are taken with the phone/camera view upright. However, when the imageView displays them, they animate properly but are rotated 90 degrees counterclockwise. Is there a way to change the orientation of animationImages
, or do I have to set each image's orientation individually?
Upvotes: 2
Views: 548
Reputation: 8759
Setting the image
property for the UIImageView
to the first image in the list of images fixes the problem. For example in my view controller (swift):
override func viewDidLoad() {
super.viewDidLoad()
if let images = self.images {
if images.count > 0 {
self.animation_view.image = images[0]
}
self.animation_view.animationImages = images
self.animation_view.animationRepeatCount = 0
self.animation_view.animationDuration = 1.0
}
}
override func viewWillAppear(animated: Bool) {
self.animation_view.startAnimating()
}
Upvotes: 1
Reputation: 7685
The simplest solution may be to just rotate the UIImageView
itself.
You can use the transform
property of UIView
to do this:
[imageView setTransform:CGAffineTransformMakeRotation(M_PI_2)];
Be aware of the fact that this will break if you start displaying images which are already in the correct orientation. These will be rotated 90 degrees clockwise as well.
Upvotes: 1