목록SwiftUI (51)
기어가더라도 제대로

UserDefault 를 사용할 때 SwiftUI 에서 조금 간편하게 할 수 있는 property wrapper struct ContentView: View { @State private var tapCount = UserDefaults.standard.integer(forKey: "Tap") var body: some View { Button("Tap count: \(tapCount)") { tapCount += 1 UserDefaults.standard.set(self.tapCount, forKey: "Tap") } } } UserDefault 에는 3가지 문제가 있습니다. 첫째, 현행 2줄의 코드로 처리가 되는점 저장은 set, 인출은 해당 데이터 타입을 불러옴 둘째, 처음에 앱을 실행할 때는 저 ..

list - forEach 는 짝궁이다. 간편하게 list를 만드는 방법도 있음 List(0..

Custom Color SwiftUI에서 다양한 곳에 사용되는 색상? 물질 있음 ShapeStyle 이라는 프로토콜 Color, Meterial, Gradients 등등의 추상타입 SwiftUI 에서 커스텀 컬러를 추가하고 싶은데, 크게 두가지 방법이 있음 Assets에 추가 시각적으로 색상을 추가할 수 있음 코드리뷰할 때 어떤 색인지 알기 어려움 색상 추가를 이미지 추가하듯이 문자열로 해야함 extension으로 추가 색상을 코드로 추가가능 깃헙에서 코드 확인 가능 커스텀 색상을 코드로 추가하는 방법임 extension ShapeStyle where Self == Color { static var darkBackground: Color { Color(red: 0.1, green: 0.1, blue: 0..