我有 UIImageView
的 IBOutletCollection
现在我需要访问其中的图像,我该怎么做?
我只能通过这段代码访问第一个和列表
myCollection.first?.image
myCollection.last?.image
我需要访问其他图片
最佳答案
IBOutletCollection
是一个数组,因此要访问它的元素,我们可以使用下标,就像我们访问普通数组中的元素一样。
访问它的元素:
myCollection[0].image //or myCollection.first?.image
myCollection[1].image
myCollection[2].image
....
myCollection.last?.image
关于swift - 访问 IBOutletCollection 中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39716312/