【问题标题】:Changing alpha value on top and bottom parts of UIImageView更改 UIImageView 顶部和底部的 alpha 值
【发布时间】:2011-09-27 03:00:29
【问题描述】:

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

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

}

【问题讨论】:

    标签: iphone objective-c uiimagepickercontroller crop alpha-transparency


    【解决方案1】:

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

    【讨论】:

    • 出色的帮助我实现了我想要对图像做的事情。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多