Skip to content

Commit

Permalink
[Add] #252 - 커스텀 체크박스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
yungu0010 committed Apr 19, 2024
1 parent b8cedc3 commit 43b127f
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@

import SwiftUI

struct CheckboxToggleStyle: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
struct CheckboxToggleStyle: ToggleStyle {
@Environment(\.isEnabled) var isEnabled

func makeBody(configuration: Configuration) -> some View {
Button(action: {
configuration.isOn.toggle()
}, label: {
HStack {
Image(configuration.isOn ? .btnSmallBoxFill : .btnSmallBox)
.imageScale(.large)
configuration.label
}
})
.buttonStyle(.plain)
.frame(width: 16, height: 16)
.disabled(!isEnabled)
}
}

#Preview {
CheckboxToggleStyle()
}

0 comments on commit 43b127f

Please sign in to comment.