最近在使用swift開發iOS的app,經常需要預覽UI
struct PostImageCell_Previews: PreviewProvider {
static var previews: some View {
let images = postList.list[0].images
let width=UIScreen.main.bounds.width
return Group{
PostImageCell(images: Array(images[0...0]),width: width)
PostImageCell(images: Array(images[0...1]),width: width)
}
}
}
有時候需要設置預覽的效果,更改預覽的大小
struct PostImageCell_Previews: PreviewProvider {
static var previews: some View {
let images = postList.list[0].images
let width=UIScreen.main.bounds.width
return Group{
PostImageCell(images: Array(images[0...0]),width: width)
PostImageCell(images: Array(images[0...1]),width: width)
}
.previewLayout(.fixed(width: width, height: 300))
}
}
這個時候發現預覽變得簡潔
喜歡可以加Q羣號:913934649,點贊,評論;
簡書: https://www.jianshu.com/u/88db5f15770d
csdn:https://me.csdn.net/beyondforme
掘金:https://juejin.im/user/5e09a9e86fb9a016271294a7