Swift/SwiftUI
-
[SwiftUI] isFavorite: Bool 활용하여 filter 해주기Swift/SwiftUI 2022. 4. 5. 21:15
주목할 곳은 15~17번째 줄이다 landmark라는 List를 iterate하면서 각각의 객체 안에 있는 isFavorite이라는 Bool type data의 value를 가지고 오면서 showFavoriteOnly라는 변수의 값을 뒤집어서 논리 연산자로 두 값을 계산하고 있다 var showFavoritesOnly = true var isFavorite = true print(!showFavoritesOnly || landmark.isFavorite) // false || true // true var showFavoritesOnly = true var isFavorite = false print(!showFavoritesOnly || landmark.isFavorite) // false || fal..
-
[SwiftUI] Binding : 다른 View 에서 변수를 가져다 써보자Swift/SwiftUI 2022. 4. 4. 21:27
PlayerView안에 isPlaying이 선언되어 있다 자식 View안에 PlayButton이라는 View의 parameter로 전달된다 PlayButton이라는 struct의 parameter로 isPlaying이 전달되었으며 PlayButton: View에서 @Binding var isPlaying: Bool 로 type을 지정해주고 변수라고 다시 한번 선언해 주어야 한다. 그렇게 되면 PlayerView에서 선언된 isPlaying과 같은 property를 사용 하게 된다. 값을 복사해온 변수가 아닌 같은 참조주소를 가진 같은 property이다
-
[SwiftUI] State : View 안에서 data에 접근해서 읽고 써보자Swift/SwiftUI 2022. 4. 4. 13:56
Apple Developer Documentation developer.apple.com Swift 문법이 아닌 Swift UI가 지원하는 녀석이다 Property를 한번 감싸주는데 그 value를 읽어오거나 쓰게끔 도와준다. "referring to the property directly" 값을 복사해 오는 것이 아닌 참조에 의해 해당 property에 접근을 하며 선언된 해당 View 안에서 사용하게 된다 만약 다른 View 에서 사용 하고 싶다면 @Binding을 쓰면 된다 그건 다음 글에서...
-
[SwiftUI] font size 지정하기Swift/SwiftUI 2022. 2. 24. 14:39
Typography - Visual Design - iOS - Human Interface Guidelines - Apple Developer Typography Apple provides two type families you can use in your iOS apps. San Francisco (SF). San Francisco is a sans serif type family that includes SF Pro, SF Pro Rounded, SF Mono, SF Compact, and SF Compact Rounded. SF Pro is the system font in iOS, mac developer.apple.com 위에 차트에서 보다시피 스위프트 ui는 원래 폰트 사이즈가 정해져있다 마치..