iOS swift 預覽設置previewLayout

最近在使用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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章