본문 바로가기

전체 글13

JS에서 멀티스레드 사용하기 https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API Web Workers API - Web APIs | MDNWeb Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usualldeveloper.mozilla.org JS는 기본적으로 싱글스레드로 동작한다. .. 2025. 1. 29.
하위뷰에서 상위뷰로 데이터 전달 (PreferenceKey, GeometryReader) [SwiftUI] 문제상황 struct BlueRectangle: View { @State var blueRectSize = CGSize(width: 20, height: 40) var body: some View { VStack { Rectangle() .frame(width: blueRectSize.width, height: blueRectSize.height) .foregroundStyle(.blue) BlackRectangle() .frame(height: 60) } } } struct BlackRectangle: View { var body: some View { HStack { Rectangle() Rectangle() Rectangle() Rectangle() } } } BlueRectangle 1개와 Bla.. 2023. 9. 27.
UICollectionViewHeader with Dynamic Height 0. Plan Dynamic Height를 구현하기 위해서 AutoLayout Constraints 제약조건으로 SubView들의 높이의 합을 구해야한다. 이를 systemLayoutSizeFitting 메서드를 통해 계산할 수 있다. 1. Apple Document + blog systemLayoutSizeFitting(_:withHorizontalFittingPriority:verticalFittingPriority:) constraints와 지정된 우선순위를 기반으로 뷰의 최적 사이즈를 반환한다. func systemLayoutSizeFitting( _ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILay.. 2023. 9. 25.
withAnimation 버그 해결 https://stackoverflow.com/questions/77022165/why-occur-animation-effect-in-swiftui Why occur animation effect in SwiftUI struct ContentView: View { var randColor: Color { Color(red: randomNumber/255, green: randomNumber/255, blue: randomNumber/255) } @State var isAnimation = false var stackoverflow.com stackoverflow에 질문을 올렸었는데, 분명히 아래의 Rectangle은 색이 변하는 애니메이션이 작동할 이유가 없다. 하지만 지속적으로 색이 변하는 애니메이션이.. 2023. 9. 1.