SwiftUI Views
1. Custom Button#
struct AFButton: View {
let title: String
var body: some View {
Text(title)
.font(.title2)
.fontWeight(.semibold)
.frame(width: 250, height: 50)
.background(Color.red)
.foregroundColor(.white)
.clipShape(RoundedRectangle(cornerSize: CGSize(width: 10, height: 10)))
}
}
// ---------------------------------
Button {
isShowingSafariView = true
} label: {
AFButton(title: "Learn More")
}
2. System Button#
3. Sheet#
Learn more: sheet(isPresented:onDismiss:content:) | Apple Developer Documentation
4. Label & .infinity
#
指定宽度或高度时使用, 填充宽度或者高度整个屏幕, 无论屏幕多宽或者多高,
查看其他文章