SwiftUI 高级List 之CardView卡片效果(2020年教程)

SwiftUI 高级List 之CardView卡片效果(2020年教程)

代码

import SwiftUI

struct ListCardView: View {
    var body: some View {
        List{
            VStack{
                Image("circle")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                HStack{
                    VStack(alignment: .leading) {
                        Text("明代")
                            .font(.headline)
                            .foregroundColor(.secondary)
                        Text("销闲清课图")
                            .font(.title)
                            .fontWeight(.black)
                            .foregroundColor(.primary)
                            .lineLimit(3)
                        Text("此《销闲清课图》卷由明代孙克弘绘制。")
                            .foregroundColor(.secondary)
                    }
                    .layoutPriority(100)
                    //将VStack 推到左侧
                    Spacer()
                }
                .padding()
            }
            .cornerRadius(20)
            .overlay(
                RoundedRectangle(cornerRadius: 10)
                    .stroke(Color(.sRGB, red: 150/255, green: 150/255, blue: 150/255, opacity: 0.1), lineWidth: 1)
            )
                .padding([.top, .horizontal])
            
            //second
            VStack{
                Image("wangguo")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                HStack{
                    VStack(alignment: .leading) {
                        Text("清朝")
                            .font(.headline)
                            .foregroundColor(.secondary)
                        Text("万国来朝图")
                            .font(.title)
                            .fontWeight(.black)
                            .foregroundColor(.primary)
                            .lineLimit(3)
                        Text("这幅《万国来朝图轴》也是北京故宫博物院藏。此卷应为清乾隆朝早期的一幅以万国来朝(万寿:崇庆皇太后七十大寿)为题材的作品。卷右上有清乾隆二十六年乾隆帝御题。")
                            .foregroundColor(.secondary)
                    }
                    .layoutPriority(100)
                    //将VStack 推到左侧
                    Spacer()
                }
                .padding()
            }
            .cornerRadius(20)
            .overlay(
                RoundedRectangle(cornerRadius: 10)
                    .stroke(Color(.sRGB, red: 150/255, green: 150/255, blue: 150/255, opacity: 0.1), lineWidth: 1)
            )
                .padding([.top, .horizontal])
        }
    }
    
}

效果

SwiftUI 高级List 之CardView卡片效果

推荐文章

CoreData篇

TextField篇

JSON文件篇

技术交流

QQ:3365059189
SwiftUI技术交流QQ群:518696470

请关注我的专栏icloudend,

https://www.jianshu.com/c/7b3e3b671970

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容