初始化UIimage数组

问题描述 投票:0回答:1

下面我的快速代码试图初始化UIimages数组。现在,该代码正在导致编译错误。我还添加了一张照片,这些照片将图像存储在Xcode中。代码如下。enter image description here

let image1 = UIImage(named: "a.png")
let image2 = UIImage(named: "b.png")
let image3 = UIImage(named: "c.png")
let image4 = UIImage(named: "d.png")
let image5 = UIImage(named: "e.png")
let image6 = UIImage(named: "f.png")
lazy var images: [UIImage?] = { [image1, image2, image3, image4, image5, image6] }()
arrays swift initialization uiimage
1个回答
0
投票

您仅需要以下行即可创建图像数组

let images = [image1, image2, image3, image4, image5, image6]
© www.soinside.com 2019 - 2024. All rights reserved.