전체 글 (12) 썸네일형 리스트형 [Swift] Property Wrappers https://github.com/swiftlang/swift-evolution/blob/main/proposals/0258-property-wrappers.md swift-evolution/proposals/0258-property-wrappers.md at main · swiftlang/swift-evolutionThis maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swiftlang/swift-evolutiongithub.com 정의프로퍼티 래퍼는프로퍼티에 적용되는 공통 로직이나 반복되는 코드를 클래스, 구조체, 열거형 타입에 하나의 타입으로 캡슐화 하여 재사용할 수 있.. [SwiftUI] 데이터 흐름 - 2 PropertyWrapper SwiftUI에서는 데이터를 다루는데 다음과 같은 도구들이 사용된다. @State@BindingObservableObject@ObservedObject@Published@EnvironmentObject@GestureState.... @StateView 자신의 UI 상태를 저장하기 위한 프로퍼티, 원천 자료.해당 View가 소유하고 관리한다는 개념을 명시적으로 나타내기 위해 항상 private를 사용하는 것이 좋다. 궁금한게SuperView에서 @State로 선언한 변수가 ChildView들에게 계속 전달되면@State로 선언한 변수가 바뀔 때 ChildView2, ChildView3.. 들도 다 업데이트 될까? struct SuperView: View { @State private var n.. [SwiftUI] 데이터 흐름 - 1 개요 SwiftUI 프레임워크는 View에서 어떤 상태를 저장하고 수정하는 방법으로- @State- @Binding등 과 같은 새로운 속성들을 제공한다. 기본적으로 SwiftUI에서 제공하는 View 프로토콜 내부에서 body가 getter 이고, getter은 기본적으로 nonmutating이기 때문에 body 내부에서 변수를 변경하는 것은 불가능하다.struct StateView_: View { private var exampleText = "예제" var body: some View { Button { exampleText = "바뀜" } label: { Text(exampleText) } }} 따라.. [SwiftUI] EnvironmentValues 개요SwiftUI에서는 뷰를 구성하는 데 필요한 각종 환경 설정과 관련된 정보를 EnvironmentValues 타입이 관리한다./// Clients of your value then access the value in the usual way, reading it/// with the ``Environment`` property wrapper, and setting it with the/// `myCustomValue` view modifier.@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)public struct EnvironmentValues : CustomStringConvertible { /// Creates an environm.. [SwiftUI] Image SwiftUI에서 image를 표현하기 위해서는 Image struct를 사용한다. Image를 사용하면 기본적으로 주어진 공간과 상관없이 고유의 크기를 유지하려 한다. resizable따라서 크기를 변경하려면 반드시 resizable() Modifier가 필요하며,resizable option을 선택할 수 있다. contentModeUIKit처럼 SwiftUI에도 이미지의 크기를 조정할 수 있는 ContentMode가 존재하는데,resizable() 을 사용하면 기본적으로 Scale To Fill이 적용된다. UIKitSwiftUI설명Scale To Fill기본 값 (resizable() 사용 시)이미지의 비율 유지: X주어진 공간을 가득 채운다.Aspect Fit.scaledToFilt()이미지 원본.. [SwiftUI] GeometryReader GeometryReader자식 View에 부모 View와 기기에 대한 크기 및 좌표계 정보를 전달하는 기능을 수행하는 ContainerViewGeometryReader의 영역에 대한 레이아웃 정보가 content로 들어가는 View에게 제공된다.@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)@frozen public struct GeometryReader : View where Content : View { public var content: (GeometryProxy) -> Content @inlinable public init(@ViewBuilder content: @escaping (GeometryProxy) -> Content.. [SwiftUI] Swift 문법 https://github.com/swiftlang/swift-evolution/blob/main/proposals/0255-omit-return.md swift-evolution/proposals/0255-omit-return.md at main · swiftlang/swift-evolutionThis maintains proposals for changes and user-visible enhancements to the Swift Programming Language. - swiftlang/swift-evolutiongithub.comOmit Return (리턴 생략)단일 표현식 리턴 생략 https://github.com/swiftlang/swift-evolution/blob/main/propo.. [SwiftUI] 트랜지션 트랜지션은..뷰 계층 구조에 새로운 뷰가 추가되거나 기존에 있던 것이 제거될 때 적용되는 애니메이션의 한 종류따라서 transition Modifier 단독으로는 동작하지 않고 animation Modifier나 withAnimation 함수와 함께 사용해야 한다. - 뷰 계층 구조에 새로운 뷰가 삽입되는 과정- 뷰 계층 구조에 이미 추가된 뷰가 제거되는 과정- 삽입과 제거가 동시에 일어나는 과정 중요한 것은 에 변화가 생겨야 하고,만약 뷰는 동일하고 그 안의 내용만 바뀌는 경우는 트랜지션이 적용되지 않는다. struct TransitionExampleView: View { @State private var showText = false var body: some View { .. 이전 1 2 다음