본문 바로가기

**226

[Swift] apple tutorials https://developer.apple.com/tutorials/app-dev-training/decoding-structured-json Decoding structured JSON | Apple Developer Documentation In this tutorial, you’ll use Swift APIs to decode earthquake information that the USGS provides. The USGS encodes the earthquake observations in JSON format, which is a popular choice for providing data on the web. You’ll access child objects within a developer.. 2023. 8. 5.
[SwiftUI] 함수로 버튼뷰 리턴받기 (some View 개념) https://da-ye.tistory.com/189 [SwiftUI] 버튼을 함수로 리턴하기func buildButton(parameter : Parameter) -> Button버튼 함수의 형식 func buildButton() -> Button { return Button { } label: { Text("첫번째 버튼입니다.") } }이런식으로 label 내 요소가 존재한다면 안에 표시해주어야함da-ye.tistory.com위와 같이 형식만 알아보고 간단한 버튼은 리턴 받았었는데, 아래와 같이 코드를 짜니 오류가 와장창,,, 여러 스타일들이 추가돼서 그런것같다 func intBtn(_ index : Int, _ num : Int) -> Button { return Button { } label: {.. 2023. 6. 30.
[SwiftUI] LaunchScreen (로딩화면 구현하기) SwiftUI에서 런치스크린 구현하는법! **AppDelegate.Swift ** import SwiftUI extension ContentView { var AppDelegate : some View { ZStack(alignment: . center){ Image("Rock").foregroundColor(Color.black) }.frame(minWidth:6000,minHeight: 5000).background(Color.white) } } ZStack안에 런치화면을 구현한다. ZStack에 그냥 backgroundColor 설정해줬는데 안되길래 그냥 Frame만들어서 다 덮어야겠다고 결정. 아마 시스템 width같은거 있을것같은데, 급해서 일단 저걸로 우겨넣음 **ContentView.Swif.. 2023. 6. 26.
[SwiftUI] 뷰에서 반복문 사용하기 (ForEach) 흔히 우리가 아는 foreach문과 SwiftUI에서의 ForEach는 다르다. struct ForEach where Data : RandomAccessCollection, ID : Hashable 함수가 아닌 구조체였던것. ID : Hashable -> 식별된 데이터 Data : RandomAccessCollection -> 콜렉션에서 가져옴 Content -> 뷰 계산 이전의 글 중 func를 버튼으로 리턴하는 함수와 함께 써본다면 다음과 같음 var body: some View { VStack { Text("컴퓨터") HStack{ ForEach(1...3 ,id: \.self) {i in rcpButton(i) } } } .padding() } ... func rcpButton(_ num : In.. 2023. 6. 26.