gpt4 book ai didi

iphone - 更改 UIImageView 顶部和底部的 alpha 值

转载 作者:行者123 更新时间:2023-12-03 21:19:14 24 4
gpt4 key购买 nike

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

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

}

最佳答案

我认为实现此目的的最佳方法是使用 mask 图像。您可以在此博客文章中找到一个很好的示例:http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html

关于iphone - 更改 UIImageView 顶部和底部的 alpha 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6554514/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com