小编Spr*_*ite的帖子

SwiftUI 披萨按钮

我想知道是否可以创建所谓的“披萨按钮”,它本身就是一个圆形视图,对角线分为 4 半(按钮),中间还有一个按钮。每一块都应该是可点击的

ZStack 不起作用,因为只有顶部按钮视图是可单击的。请给我一个建议,我该怎么做。

“披萨按钮”

我的测试代码:和资产

struct FirstView: View {
    var body: some View {
        VStack {
            HStack {
                Button(action: {
                    
                }, label: {
                    Text("Menu")
                        .frame(width: 88, height: 44)
                        .background(.gray)
                        .cornerRadius(12)
                })
                
                Spacer()
                
                Button(action: {
                    
                }, label: {
                    Text("Settings")
                        .frame(width: 88, height: 44)
                        .background(.gray)
                        .cornerRadius(12)
                })
                
              
            }
            .padding(.horizontal, 40)
            
            ZStack {
    
                Button(action: {
                    print("1")
                }, label: {
                    Image("left_btn")
                        .resizable()
                        .scaledToFit()
                        .border(.green)
                        .frame(width: 215, height: 215)
                        .edgesIgnoringSafeArea(.all)
                })
                
                Button(action: {
                    print("2")
                }, label: {
                    Image("top_btn")
                        .resizable()
                        .scaledToFit()
                        .frame(width: 215, height: 215) …
Run Code Online (Sandbox Code Playgroud)

swift swiftui

2
推荐指数
1
解决办法
120
查看次数

标签 统计

swift ×1

swiftui ×1