gpt4 book ai didi

iphone - 从 CGPoints 数组中设置按钮框架(仅 x 和 y 位置)

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

1)我有一个长度为10的数组,名为“pointArrar”。该数组的每个索引上都包含CGPoints
2)我还有10个按钮。
现在我想从 CGPoints 数组中设置按钮框架(仅 x 和 y 位置)。
我只想知道如何从数组中包含的 CGPoint 设置按钮 x 和 y 位置。

最佳答案

嗯,这非常符合逻辑。

假设你的数组就像

NSArray * pointArrar = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:CGPointMake(5.5, 6.6)],
[NSValue valueWithCGPoint:CGPointMake(7.7, 8.8)],
nil];

然后要添加到您的各种按钮,您需要简单地将所有点放入一个循环中,如

for(int i=0; i<[pointArrar count] ; i++)
{
NSValue *val = [pointArrar objectAtIndex:i];
CGPoint p = [val CGPointValue];
[Button setCenter:p];
}

此处所有的点都已添加到您的按钮中。希望这对你有用:)

关于iphone - 从 CGPoints 数组中设置按钮框架(仅 x 和 y 位置),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18266504/

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