RadioButton.swift 633 B

123456789101112131415161718192021222324252627
  1. //
  2. // RadioButton.swift
  3. // fiveConstant
  4. //
  5. // Created by 李建 on 2023/1/14.
  6. //
  7. import SwiftUI
  8. struct RadioButton: View {
  9. @Binding var selected: Bool
  10. var body: some View {
  11. Button(action: {
  12. self.selected.toggle()
  13. }, label: {
  14. Image(systemName: self.selected ? "checkmark.circle.fill" : "circle")
  15. .foregroundColor(self.selected ? Color("MainColor") : Color.gray)
  16. })
  17. }
  18. }
  19. struct RadioButton_Previews: PreviewProvider {
  20. @State static var isseelcted: Bool = false
  21. static var previews: some View {
  22. RadioButton(selected: $isseelcted)
  23. }
  24. }