gpt4 book ai didi

ios - 从 Objective C 中的 UIView 中删除绘图矩形

转载 作者:行者123 更新时间:2023-11-28 19:55:29 24 4
gpt4 key购买 nike

我曾经使用以下代码在 UIView(例如:“candleContainer”)内创建矩形:

UIView *myBox  = [[UIView alloc] initWithFrame:CGRectMake(marginX, marginY, rectWidth, rectHeight)];
[self.candleContainer addSubview:myBox];

但是如何删除所有或每个已绘制的矩形。我通过从 super View 中删除 'candleContainer' UIView 来做到这一点。但这不是实际的解决方案,对吧?我只想删除那些矩形。我该怎么做?

最佳答案

 NSArray *viewsToRemove = [self.view subviews];

for (UIView *view in viewsToRemove) {

[view removeFromSuperview];
}

关于ios - 从 Objective C 中的 UIView 中删除绘图矩形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26708029/

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