gpt4 book ai didi

ios - 用函数修改多张图片

转载 作者:行者123 更新时间:2023-11-29 13:03:46 25 4
gpt4 key购买 nike

C 大师们!我需要你的帮助!我有以下代码块,用于修改图像以使其成为带有彩色边框的椭圆形。它工作完美。现在,我还有 13 张其他图片要制作,我不想为每一张都打字。我确信将它们存储到一个数组中并传递到一个函数中会容易得多,但我对如何做到这一点感到困惑。

CALayer *A = [img1 layer];
[A setMasksToBounds:YES];
[A setCornerRadius:31.0];
[A setBorderWidth:2.5];
[A setBorderColor:[[UIColor blueColor] CGColor]];

我希望有人可以教我并帮助我将其转化为实用的学习体验!感谢您的帮助。

最佳答案

to store them into an array and pass into a function

是的。这是一个选择:

- (void)makeImageViewsOval:(NSArray*)imgArray {
for (UIImageView *currentImage in imgArray) {
CALayer *A = currentImage.layer;
[A setMasksToBounds:YES];
[A setCornerRadius:31.0];
[A setBorderWidth:2.5];
[A setBorderColor:[[UIColor blueColor] CGColor]];
}
}

然后您可以像这样轻松地提供您的 UIImageView:

[self makeImageViewsOval:@[imgView1, imgView2, imgView3]];

关于ios - 用函数修改多张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19145531/

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