如何在 UIView 中访问 UIScrollView 中的所有 UIButton? [英] How To Access All UIButtons within a UIScrollView within a UIView?

查看:26
本文介绍了如何在 UIView 中访问 UIScrollView 中的所有 UIButton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下内容尝试访问位于 UIView 内 UIScrollView 内的所有 UIButton.问题是代码似乎没有定位按钮并设置边框属性.

I am using the following to try to access all the UIButtons located inside of a UIScrollView within a UIView. The problem is that the code doesn't seem to locate the buttons and set the border property.

UIView -> UIScrollView -> UIButtons.

UIView -> UIScrollView -> UIButtons.

我基本上想遍历按钮并设置边框属性.

I basically want to loop through the buttons and set the border property.

for(UIView *v in [self.viewLightLeakChoices subviews]) {

    if([v isKindOfClass:[UIButton class]]) {

        v.layer.borderWidth = 0;

    }

}

推荐答案

感谢各位的帮助.我最终做了一堆 for 循环来处理 UIButtons.

Thanks for the help guys. I ended up doing a bunch of for loops to get down to the UIButtons.

for(UIView *v in [self.viewLightLeakChoices subviews]) {

    if([v isKindOfClass:[UIScrollView class]]) {

        for(UIView *subView in [v subviews]) {

            for(UIButton *btn in [subView subviews]) {

                btn.layer.borderWidth = 0;

            }

        }

    }

}

这篇关于如何在 UIView 中访问 UIScrollView 中的所有 UIButton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆