Changing alpha value on top and bottom parts of UIImageView
I'm picking up a photo from the photo albums, however I would like to be able to do the following with it:
Change the alpha value of the top and bottom parts (lets say 20 pixles from the top and 20 pixles from the bottom) to 0.5
then copy only the unchanged part in the middle and assign it to another UIImageView
I've got this code:
@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.ima开发者_开发技巧ge = [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 */
}
I think the best way to achieve this is to use a mask image. You can find a good example on this blog post : http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
精彩评论