【问题标题】:Changing images of UIImageView in UIStackView在 UIStackView 中更改 UIImageView 的图像
【发布时间】:2019-09-24 04:54:31
【问题描述】:

我有 UIStackView(红色)。当我将这个带有图片的 stackView imageView 放入时,这个 imageView 变成了 UIView,之后即使我想要也无法更改图像。

我有滑块,在我的堆栈视图中有图像更改计数器,以及应该更改我的 imageView 图像的按钮。

Stack View 只包含 UIView,不包含 UIIMAgeView。因此,我无法更改 imageView 图像。

【问题讨论】:

    标签: ios swift xcode uiimageview uistackview


    【解决方案1】:

    您需要将stackView.arrangedSubviews 元素转换为UIImageView

    @objc func buttonAction(_ sender: UIButton) {
        for case let imageView as UIImageView in stackView.arrangedSubviews {
            imageView.image = newImage
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-05
      • 1970-01-01
      相关资源
      最近更新 更多