I am trying to convert 10 UIImages in .gif format programatically using IOS Xcode 4.5 and save it in gallery, but am having no luck I even tried a question at stackoverflow Create and and export an animated gif via iOS? I am not getting the point what are the variables like __bridge id used and how can i assign these images to the method please help ....
2 回答
instead of converting image in to Gif apple provide UIImageView.animationImages proparty that you can Animation Number of images one by one like gif. like Bellow code:-
UIImage *statusImage = [UIImage imageNamed:@"status1.png"];
YourImageView = [[UIImageView alloc]
initWithImage:statusImage];
//Add more images which will be used for the animation
YourImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"status1.png"],
[UIImage imageNamed:@"status2.png"],
[UIImage imageNamed:@"status3.png"],
[UIImage imageNamed:@"status4.png"],
[UIImage imageNamed:@"status5.png"],
[UIImage imageNamed:@"status6.png"],
[UIImage imageNamed:@"status7.png"],
[UIImage imageNamed:@"status8.png"],
[UIImage imageNamed:@"status9.png"],
nil];
//setFrame of postion on imageView
YourImageView.frame = CGRectMake(
self.view.frame.size.width/2
-statusImage.size.width/2,
self.view.frame.size.height/2
-statusImage.size.height/2,
statusImage.size.width,
statusImage.size.height);
YourImageView.center=CGPointMake(self.view.frame.size.width /2, (self.view.frame.size.height)/2);
YourImageView.animationDuration = 1;
[self.view addSubview:YourImageView];
First of all you should check for your problem in Apple Documentation. Everything is given there. What you need is to Research & Read.
You should try the ImageIO framework. It can convert .png files into CGImageRef
objects and then export the CGImageRefs
to .gif files.
To save Images to Photo Library :UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
Also Documented in UIKit.