SwiftUI_visionOS_Note

.buttonStyle & .controlSize

May 7, 2024
1 min read|
//
//  ContentView.swift
//  buttonStyle_controlSize
//
//  Created by Yoon Ro on 2024-05-07.
//

import SwiftUI
import RealityKit
import RealityKitContent

struct ContentView: View {
    var body: some View {
        VStack {
            Model3D(named: "Scene", bundle: realityKitContentBundle)
                .padding(.bottom, 50)

//            
//            Button("Button Title"){
//                print("is it working?")
//            }
//            .frame(height: 55)
//            .frame(maxWidth: .infinity)
//            .buttonStyle(AccessoryBarButtonStyle())
            
            Button("Button Title"){
                print("is it working?")
            }
            .frame(height: 55)
            .frame(maxWidth: .infinity)
//            .buttonStyle(PlainButtonStyle())
            .controlSize(.regular)
            
            Button("Button Title"){
                print("is it working?")
            }
            .frame(height: 55)
            .frame(maxWidth: .infinity)
//            .buttonStyle(DefaultButtonStyle())
            .controlSize(.large)
            
            Button("Button Title"){
                print("is it working?")
            }
            .frame(height: 55)
            .frame(maxWidth: .infinity)
//            .buttonStyle(BorderlessButtonStyle())
            .controlSize(.extraLarge)

            
            
            Button("Button Title"){
                print("is it working?")
            }
            .frame(height: 55)
            .frame(maxWidth: .infinity)
//            .buttonStyle(BorderedProminentButtonStyle())
            .controlSize(.small)
            
            Button("Button Title"){
                print("is it working?")
            }
            .frame(height: 55)
            .frame(maxWidth: .infinity)
//            .buttonStyle(.borderless)
            .controlSize(.mini)
   
            Button {
            
            } label: {
            
            }
            .buttonBorderShape(...)
  
        }
    }
}

#Preview(windowStyle: .automatic) {
    ContentView()
}
swift

For the button Style, which one should I use?

.buttonStyle(BorderlessButtonStyle())

or

.buttonStyle(.borderless)

Subscribe to our newsletter

Get the latest news and updates from our team