我刚到swiftui岁.我正在制作一个登录屏幕,在其中我必须使用apple and gmail个按钮登录.我正在使用自定义视图来设计按钮.以下是自定义按钮视图的代码:
struct CustomSocialButton: View {
var ImgName: String
var body: some View {
Button(action: {
print("button pressed")
}) {
Image(ImgName)
.renderingMode(.original)
}
}
}
struct CustomSocialButton_Previews: PreviewProvider {
static var previews: some View {
CustomSocialButton(ImgName: ImageName.appleSignin.rawValue)
}
}
我正在将图像名称保存到我的常量文件中.
问题是,当我将其设置为实际的login view,并将其设置为width和height时.它不需要那个高度和宽度.以下是按钮的代码:
HStack(spacing: 10) {
CustomSocialButton(ImgName: ImageName.appleSignin.rawValue)
.frame(width: 48, height: 48)
CustomSocialButton(ImgName: ImageName.googleSignin.rawValue)
.frame(width: 48, height: 48)
}
This is the screenshot of my login View:
有人知道我做错了什么吗?