默认自定义控件时都是全屏iPhone
样式预览
如果想要实现类似于xib
那种特定尺寸的效果, 可以通过Group
和previewLayout
实现
e.g. 默认状态下新建控件时的样式
e.g. 修改后
两种写法对比:
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
LoginView(account: "", password: "", loginCallback: nil)
}
}
struct LoginView_Previews: PreviewProvider {
static var previews: some View {
let width = UIScreen.main.bounds.size.width
return Group {
LoginView(account: "", password: "", loginCallback: nil)
.previewLayout(.fixed(width: width, height: 300))
}
}
}