Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 更改UIImageView顶部和底部的alpha值_Iphone_Objective C_Uiimagepickercontroller_Crop_Alpha Transparency - Fatal编程技术网

Iphone 更改UIImageView顶部和底部的alpha值

Iphone 更改UIImageView顶部和底部的alpha值,iphone,objective-c,uiimagepickercontroller,crop,alpha-transparency,Iphone,Objective C,Uiimagepickercontroller,Crop,Alpha Transparency,我正在从相册中选取一张照片,但我希望能够使用它执行以下操作: 将顶部和底部零件的alpha值(例如,从顶部起20个pixles,从底部起20个pixles)更改为0.5 >P>然后只复制中间部分,并将其分配给另一个UIVIEVIEW 我有这个密码: @synthesize imageView, croppedImageView, choosePhotoBtn, takePhotoBtn; -(IBAction) getPhoto:(id) sender { UIImagePicke

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

  • 将顶部和底部零件的alpha值(例如,从顶部起20个pixles,从底部起20个pixles)更改为0.5

  • >P>然后只复制中间部分,并将其分配给另一个UIVIEVIEW

    我有这个密码:

    @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 */
    
    }
    

    我认为实现这一点的最佳方法是使用遮罩图像。你可以在这篇博文中找到一个很好的例子:

    非常棒,它帮助我实现了我想要的图像。非常感谢。