swiftUI
-
[SwiftUI] clipShapeSwiftUI 2023. 8. 7. 10:56
๋ทฐ์ ๋ํ ํด๋ฆฌํ ๋ชจ์์ ์ค์ ํ๋ค. func clipShape( _ shape: S, style: FillStyle = FillStyle() ) -> some View where S : Shape shape ํ๋ผ๋ฏธํฐ๋ ๋ทฐ์ ์ฌ์ฉํ ํด๋ฆฌํ ๋ชจ์์ผ๋ก, ๊ฐ๋ก ์ธ๋ก ๋น์จ์ ์ ์งํ๋ฉด์ ๋ทฐ์ ํ๋ ์์ ์ฑ์ด๋ค. shape ํ๋ผ๋ฏธํฐ๋ Shape ํ๋กํ ์ฝ์ ์ฑํํ๋ค. style ํ๋ผ๋ฏธํฐ๋ ๋ชจ์์ ๋์คํฐํํ ๋ ์ฌ์ฉํ fill ์คํ์ผ๋ก, ๊ธฐ๋ณธ๊ฐ์ด ์กด์ฌํ๋ค. ์ฐธ๊ณ ๋ก FillStyle์ ๋ฒกํฐ ๋ํ์ ๋์คํฐํํ๊ธฐ ์ํ ์คํ์ผ๋ก, ๊ตฌ์กฐ์ฒด์ด๋ค. ์ฌ๊ธฐ์ ๋์คํฐํ๋, ๊ทธ๋ํฝ์ ๋ ๋๋งํ๊ธฐ ์ํ ๋ฐฉ์ ์ค ํ๋๋ก, ํ๋ฉด์ ์ค๋ธ์ ํธ๋ฅผ ํฝ์ ๋ก ๋งคํํ๋ ๊ฒ์ ์๋ฏธํ๋ค. style์ ์ฌ์ฉํด์ ๋ํ์ ๋์คํฐํ๋ฅผ ์ ์ํ๊ณ ๋ทฐ์ shape๋ฅผ ํด๋ฆฌํํ๋ค..
-
[SwiftUI] DragGestureiOS 2023. 8. 4. 14:17
DragGesture() .updating($translation){ value, state, _ in print("๐state (ํ์ฌ ์ํ) ", state, " ๐value.translation.height (์ ๋ฐ์ดํธ ๋ ์ํ)", value.translation.height) state = translation } } DragGesture๋ ๋๋๊ทธ ์ด๋ฒคํธ ์ํ์ค๊ฐ ๋ณ๊ฒฝ๋ ๋ ์ก์ ์ ํธ์ถํ๋ ๋๋๊ทธ ๋ชจ์ ์ด๋ค. ๋ทฐ์์ ๋๋๊ทธ ์ ์ค์ฒ๋ฅผ ์ธ์ํ๋ ค๋ฉด ์ ์ค์ฒ๋ฅผ ๋ง๋ค๊ณ ๊ตฌ์ฑํ ๋ค์, gesture(_:including:) ๋ชจ๋ํ์ด์ด๋ฅผ ์ฌ์ฉํด์ ๋ทฐ์ ์ถ๊ฐํ๋ค. ๋ค์์ ์์ ๋๋๊ทธ ์ ์ค์ฒ๋ฅผ ์ถ๊ฐํ๊ณ , ์ฌ์ฉ์๊ฐ ๋๋๊ทธ ์ ์ค์ฒ๋ฅผ ์ํํ๋ ๋์ ์์ ์์์ ๋ณ๊ฒฝํ๋ ์ฝ๋๋ค. struct DragGestureView: V..
-
[SwiftUI] ๋๋ฐ์ด์ค์ width, height ๊ตฌํ๊ธฐiOS 2023. 8. 3. 14:18
SwiftUI์์ ๋๋ฐ์ด์ค์ ์ฌ์ด์ฆ (width, height)๋ฅผ ๊ตฌํ๋ ๋ฐฉ๋ฒ์ 2๊ฐ์ง๊ฐ ์๋ค. 1. GeometryReader ์ฌ์ฉํ๊ธฐ import SwiftUI struct ContentView: View { var body: some View { GeometryReader { geometry in ZStack { Color .yellow .frame( width: geometry.size.width, height: geometry.size.height ) VStack { Text("Width \(geometry.size.width)") Text("Height \(geometry.size.height)") } } } } } struct ContentView_Previews: PreviewProvide..
-
[SwiftUI] SwiftUI์์ UIKit View ์ฌ์ฉํ๊ธฐ์นดํ ๊ณ ๋ฆฌ ์์ 2023. 7. 26. 14:12
๋จผ์ UIViewPresentable์ ์์ฑํฉ๋๋ค. UIViewPresentable ํ๋กํ ์ฝ์ UIKit ๋ทฐ๋ฅผ ๋ํ๋ด๋ SwiftUI ๋ทฐ์ ๋๋ค. protocol UIViewPresentable: View where Self.Body == Never ์์์ ๋ณผ ์ ์๋ฏ์ด, UIViewPresentable์ View ํ๋กํ ์ฝ์ ์ค์ํ๊ธฐ ๋๋ฌธ์ SwiftUI์์ ๋ทฐ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค. UIViewPresentable์ UIKit ๋ทฐ์ SwiftUI ์ฌ์ด์ ๋ธ๋ฆฟ์ง ์ญํ ์ ํ๋๋ฐ, ๋ช ๊ฐ์ง ๋จ๊ณ๋ฅผ ์ํํด์ผ ํฉ๋๋ค. UIViewPresentable์ ์ฑํํ๋ RepresentedMyView๋ฅผ ์์ฑํฉ๋๋ค. import SwiftUI struct RepresentedMyView: UIViewPresentable {..
-
[iOS] SnapshotTesting with SwiftUI (v1.11.0)iOS 2023. 4. 5. 08:48
SnapshotTesting SnapshotTesting์ ํตํด UI์ ์ ํจ์ฑ์ ๊ฒ์ฌํ๊ณ , ์ฝ๋ ๋ณ๊ฒฝ์ด ๋น๋ํ UI์ ์ํฅ์ ๋ฏธ์น์ง ์์๋์ง ํ์ธํ๋ค. SnapshotTesting์ด๋? Snapshot Test๋ฅผ ์ฌ์ฉํ๋ฉด ํ ์คํธ ์์ ์ UI์ ์ค๋ ์ท์ ๊ธฐ์ค์ (baseline)์ด๋ผ๊ณ ํ๋ ์ ํจํ UI ์ค๋ ์ท๊ณผ ๋น๊ตํ์ฌ UI๋ฅผ ๊ฒ์ฆํ ์ ์์ต๋๋ค. ํ ์คํธ ๋ฌ๋๋ ํ์ฌ ์ค๋ ์ท์ ๊ธฐ์ค ์ค๋ ์ท๊ณผ ๋น๊ตํ๊ณ , ์ค๋ ์ท ๊ฐ์ ์ฐจ์ด๊ฐ ์์ ๊ฒฝ์ฐ, UI๋ ๋ณ๊ฒฝ๋ ๊ฒ์ด๋ฏ๋ก ํ ์คํธ๊ฐ ์คํจํฉ๋๋ค. GitHub - pointfreeco/swift-snapshot-testing: ๐ธ Delightful Swift snapshot testing. ๐ธ Delightful Swift snapshot testing. Contribute ..
-
[Swift] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") ์ด์ ํด๊ฒฐSwift 2023. 4. 4. 18:31
์๋ฎฌ๋ ์ดํฐ์์๋ ๋์ค์ง ์์์ง๋ง, ์ค ๊ธฐ๊ธฐ์์ ์คํํ๋ ๋์ค๋ ๊ฒฝ๊ณ ๋ฉ์์ง! [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") ์ฐพ์๋ณด๋ Scene์ ์ฌ์ฉํ์ง ์๊ธฐ ๋๋ฌธ์ ๋์ค๋ ๊ฒ ๊ฐ์๋ฐ, ์๋์ ๊ฐ์ด Info.plist๋ฅผ ์์ ํ๋ฉด ๋๋ค. 1) Tuist ์ฌ์ฉ ์ [ "UIApplicationSceneManifest": [ "UIApplicationSupportsMultipleScenes": false, "UISceneConfigurations": [:] ] ] 2) Info.plist ์์ค ์ฝ๋ ์ง์ ์์ ์ UIApplication..