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
@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 */
}
我认为实现这一点的最佳方法是使用遮罩图像。你可以在这篇博文中找到一个很好的例子:非常棒,它帮助我实现了我想要的图像。非常感谢。