본문 바로가기

전체 글

(33)
SwiftUI 텍스트 포맷 빠르게 알아보기 💫 Currencystruct CurrencyView: View { private let 💰 = 100_000 var body: some View { VStack { Text(💰, format: .currency(code: "KRW")) Text(💰, format: .currency(code: "USD")) Text(💰, format: .currency(code: "GBP")) } }}code에는 ISO-4217 코드를 찾아서 입력하면 된다. 원화는 소숫점을 표시하지 않지만 달러나 파운드 스털링같은 경우에는 소숫점 둘째자리까지 표시해준다.💫 Percentstruct PercentView:..
Swift OpenAPI Generator 사용해보기 💫 OpenAPI? OpenAPI는 RESTful API Spec을 yaml이나 json으로 표현하는 표준화된 문서이다. 표현된 yaml이나 json을 이용하면 개발자가 생성한 API들을 문서화하거나 코드를 자동으로 생성하여 사용할 수 있다. 대표적으로 Swagger UI가 있다. 💫 Swift OpenAPI Generator 이미 기존에도 OpenAPI를 활용하여 코드를 생성해주는 라이브러리나 플러그인들이 있었지만 지금 소개하는 Swift OpenAPI Generator는 Apple에서 개발하고 Xcode와 최적화가 잘 되어있다고 한다. 깃허브 https://github.com/apple/swift-openapi-generator GitHub - apple/swift-openapi-generator..
SwiftUI 뷰 업데이트를 반복하지 않는 방법 https://fatbobman.com/en/posts/avoid_repeated_calculations_of_swiftui_views/ How to Avoid Repeating SwiftUI View Updates | Fatbobman's Blog This article will guide you in optimizing view calculations in SwiftUI. The methods include optimizing construction parameters, breaking down views, implementing Equatable, and controlling event sources. Understanding these principles is crucial for excell f..
SwiftUI의 주요 프로퍼티 래퍼 탐색: @State, @Binding, @StateObject, @ObservedObject, @EnvironmentObject, 그리고 @Environment https://fatbobman.com/en/posts/exploring-key-property-wrappers-in-swiftui/ Exploring Key Property Wrappers in SwiftUI: @State, @Binding, @StateObject, @ObservedObject, @EnvironmentObject, and @Environmen In this article, we will explore several property wrappers that are frequently used and crucial in SwiftUI development. This article aims to provide an overview of the main functions and usage c..
SwiftUI의 AttributedString사용해보기 (feat. hacking with swift) https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-advanced-text-styling-using-attributedstring 위 글을 참고하여 구현한 전체 코드 및 미리보기 미리보기 샘플 코드 import SwiftUI struct ContentView: View { var body: some View { VStack(spacing: 10) { Case1() Case2() Case3() Case4() Case5() Case6() Case7() Case8() Case9() } } } #Preview { ContentView() } struct Case1: View { var message: AttributedString { var res..
Xcode 파일 헤더 "Created by 이름..." 변경하기 Xcode에서 파일을 생성할 때마다 생기는 상단 헤더 부분(1~6라인)에 표시되는 이름이나 형식을 변경해보자! 일단 표시되는 이름은 기본적으로 맥OS의 유저이름이 표시되므로 맥 설정에서 직접 변경할 수도 있지만 Xcode 9버전 이상에서는 설정값을 수정하여 표시되는 이름이나 형식을 바꿀수 있다. 아래 단계를 따라서 이름을 수정해보자! 1. 프로젝트에서 File > New > File...을 클릭한뒤 Property List를 클릭한다. 2. 파일이름을 IDETemplateMacros.plist 로 설정하고 저장한다. (사진은 오타ㅠㅠ) 3. 아래처럼 프로퍼티 리스트가 있고 Root아래에 FULLUSERNAME을 키로하고 값을 원하는 이름을 설정한다. 4. IDETemplateMacros.plist 파일을..
SwiftUI Bordering (inside, half, outside) extension View { func insideBorder( _ content: C, shape: S = Rectangle(), lineWidth: CGFloat = 1 ) -> some View where C: ShapeStyle, S: InsettableShape { overlay( shape .strokeBorder(content, lineWidth: lineWidth) ) } func halfBorder( _ content: C, shape: S = Rectangle(), lineWidth: CGFloat = 1 ) -> some View where C: ShapeStyle, S: InsettableShape { overlay( shape .stroke(content, lineWidth: li..
Typescript의 자주쓰는 유틸리티 타입들 (Pick, Omit, Partial, Exclude, Record) ▶︎ Pick 특정 타입의 속성을 뽑아 새로운 타입을 생성한다. interface Profile { id: string address: string } type ProfileId = Pick // 위와 같은 타입 // type ProfileId = { // id: string // } ▶︎ Omit Pick과 반대로 특정 타입의 속성을 제외한 나머지를 뽑아 새로운 타입을 생성한다. interface Profile { id: string address: string } type ProfileAddress = Omit // 위와 같은 타입 // type ProfileAddress = { // address: string // } ▶︎ Partial 특정 타입의 속성을 Optialnal하게 바꾼 새로운 타입을..