程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-保存一張被標簽覆蓋的圖片

ios-保存一張被標簽覆蓋的圖片

編輯:編程綜合問答
保存一張被標簽覆蓋的圖片

在保存相片的時候將一些數據疊加到相片上,代碼如下:不知道有沒有簡單的方法實現?

- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info 
{         
    UIImage *cameraImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    UIImageView *imageViewToSave = [[UIImageView alloc] initWithImage:cameraImage];
    CGRect textFrame = CGRectMake(0, 0, imageViewToSave.frame.size.width-20, 325);
    UILabel *tempLabel = [[UILabel alloc] initWithFrame:textFrame];
    tempLabel.text = self.temperatureText.text;
    tempLabel.font = self.imageLabelFont;
    tempLabel.adjustsFontSizeToFitWidth = YES;
    tempLabel.textAlignment = NSTextAlignmentRight;
    tempLabel.textColor = self.tempGreen;
    tempLabel.backgroundColor = [UIColor clearColor];
    [imageViewToSave addSubview:tempLabel];

    UIGraphicsBeginImageContext(imageViewToSave.bounds.size);
    [imageViewToSave.layer renderInContext:UIGraphicsGetCurrentContext()];

    cameraImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    [self.library saveImage:cameraImage toAlbum:@"Node Therma" withCompletionBlock:^(NSError *error) 
    {
        if (error!=nil) 
        {
            NSLog(@"Big error: %@", [error description]);
        }
    }];
}

最佳回答:


截屏吧

        UIGraphicsBeginImageContextWithOptions(pageView.page.bounds.size, YES, zoomScale);
        [pageView.page.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *uiImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved