struct ICardView:View{
var image:String = "card"
var category:String = "SwiftUI"
var heading:String = "By default, both the text stack and the spacer occupy half of the parent view"
var author:String = "Write By Liyulong"
var body: some View {
VStack{
Image("card", bundle: nil)
.resizable()
.aspectRatio(contentMode: ContentMode.fit)
HStack {
VStack(alignment: .leading) {
Text(category).font(.headline).foregroundColor(.secondary)
Text(heading).font(.title).fontWeight(Font.Weight.black)
.lineLimit(3).foregroundColor(.primary)
Text(author).font(.caption).foregroundColor(Color.secondary)
}//使用.layoutPriority(layoutPriority)修改所占空间
Spacer()
}.padding()
}
.cornerRadius(10)
.overlay(RoundedRectangle(cornerRadius: 10).stroke(Color.gray)).padding([.top,.horizontal])
}
}