开发者

Changing alpha value on top and bottom parts of UIImageView

开发者 https://www.devze.com 2023-03-16 16:55 出处:网络
I\'m picking up a photo from the photo albums, however I would like to be able to do the following with it:

I'm picking up a photo from the photo albums, however I would like to be able to do the following with it:

  1. 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

  2. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消