美文网首页
iOS swift 预览设置previewLayout

iOS swift 预览设置previewLayout

作者: 张漂亮1号 | 来源:发表于2020-05-19 19:21 被阅读0次

    最近在使用swift开发iOS的app,经常需要预览UI

    image
    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))
            
        }
    }
    

    这个时候发现预览变得简洁

    image

    喜欢可以加Q群号:913934649,点赞,评论;

    简书: https://www.jianshu.com/u/88db5f15770d

    csdn:https://me.csdn.net/beyondforme

    掘金:https://juejin.im/user/5e09a9e86fb9a016271294a7

    相关文章

      网友评论

          本文标题:iOS swift 预览设置previewLayout

          本文链接:https://www.haomeiwen.com/subject/ojkiohtx.html