3
我想将图像以圆形图像的形式保存到iOS中的相册中。我试图以圆形掩盖图像,并且在图像视图中工作正常,但是当我保存同一图像时,它将被保存为原始图像。IOS将图像保存为cameraRoll中的圆圈
这里是我的代码:
@implementation ViewController
@synthesize imageview, photo;
- (void)viewDidLoad
{
[super viewDidLoad];
self.imageview.layer.masksToBounds = YES;
self.imageview.layer.cornerRadius = imageview.bounds.size.width/2;
self.imageview.layer.borderWidth = 1.0;
self.imageview.layer.borderColor =[UIColor colorWithRed:13/255 green:70/255 blue:131/255 alpha:1.0].CGColor;}
-(IBAction)takephoto:(id)sender{
picker1 = [[UIImagePickerController alloc]init];
picker1.delegate = self;
[picker1 setSourceType:(UIImagePickerControllerSourceTypeCamera)];
[self presentViewController:picker1 animated:YES completion:NULL];
}
-(IBAction)chooseExisting:(id)sender{
picker2 = [[UIImagePickerController alloc]init];
picker2.delegate = self;
[picker2 setSourceType:(UIImagePickerControllerSourceTypePhotoLibrary)];
[self presentViewController:picker2 animated:YES completion:NULL];}
- (IBAction)save:(id)sender {
//NSString *shareText = @"download my add with the follow up link";for textwrking.
NSArray *itemsToShare [email protected][imageview.image];
UIActivityViewController *activityVC =[[UIActivityViewController alloc]initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes [email protected][UIActivityTypePostToFacebook /* this is like excuding activities like fb,twitterand all whtever we login on ios, we can use this code */];
[self presentViewController:activityVC animated:YES completion:nil];}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
photo=[info objectForKey:UIImagePickerControllerOriginalImage];
[imageview setImage:photo];
[self dismissViewControllerAnimated:YES completion:NULL];}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[self dismissViewControllerAnimated:YES completion:NULL];}
`
试过这个仍然保存为正常图像请别人帮我 – anjani
仍然没有工作,我可以发送我的文件,你可以给我们的电子邮件ID请看看它会有所帮助。, – anjani
satheesh4590 @ gmail。 com – satheeshwaran