2

我正在从相册中挑选一张照片,但是我希望能够使用它执行以下操作:

  1. 将顶部和底部的 alpha 值(假设顶部 20 个像素和底部 20 个像素)更改为 0.5

  2. 然后只复制中间未更改的部分并将其分配给另一个 UIImageView

我有这个代码:

@synthesize imageView, croppedImageView, choosePhotoBtn, takePhotoBtn;

-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;

    if((UIButton *) sender == choosePhotoBtn) {
        picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    } else {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }


    [self presentModalViewController:picker animated:YES];
}



-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];
    [picker release];
    imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; 

        /* then here I want to change the alpha value of the top and bottom parts */
        /* then copy the unchanged part then assign it to the image value of croppedImageView */

}
4

1 回答 1

1

我认为实现这一目标的最佳方法是使用蒙版图像。你可以在这篇博文中找到一个很好的例子:http: //iosdevelopertips.com/cocoa/how-to-mask-an-image.html

于 2011-07-05T08:28:02.527 回答