简体   繁体   English

圆角矩形作为 swiftUI 中的背景

[英]rounded rectangle as a background in swiftUI

I tried to do an overlay, but it doesn't work,我试图做一个覆盖,但它不起作用, 底部问题 That part on the bottom keeps bugging me.底部的那部分一直困扰着我。 is there any other method beside doing an overlay of a rectangle??除了做一个矩形的覆盖之外还有其他方法吗?

ZStack {
                    RoundedRectangle(cornerRadius: 15)
                        .foregroundColor(Color("Hello"))
                        .frame(height: 700, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                        .overlay(
                            VStack {
                                RoundedRectangle(cornerRadius: 15)
                                    .frame(width:381, height: 130.36, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                                    .shadow(radius: 4,y:3)
                                    .foregroundColor(.white)
                                    .overlay(
                                            HStack {
                                                Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
                                                    ButtonBig(ButtonText: "Keuangan",ButtonIcon: "creditcard.fill")
                                                }
                                                Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
                                                    ButtonBig(ButtonText: "Penjurusan",ButtonIcon: "figure.walk")
                                                }
                                                Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) {
                                                    ButtonBig(ButtonText: "Status",ButtonIcon: "person.crop.circle.badge.plus")
                                                }
                                        }.buttonStyle(PlainButtonStyle()))
                                RoundedRectangle(cornerRadius: 15)
                                    .frame(width:381, height: 535, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                                    .shadow(radius: 4,y:3)
                                    .foregroundColor(.white)
                            }

在此处输入图像描述

I wanted to create something like that basically我想基本上创造类似的东西

if there's a library for it, please do tell me.如果有图书馆,请告诉我。 Thank you谢谢

Try these 2 modifiers:试试这 2 个修饰符:

.background(RoundedRectangle(cornerRadius: 10))
.clipped()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM