본문 바로가기

전체 글226

[SwiftUI] Extra arguments at positions #11, #12 in call 1개의 뷰에 10개 이상의 뷰를 넣을 수 없음. 15개의 Text 뷰에서 1개의 Group, 7개의 Text로 만들어줘서 총 8개이기 때문에 가능한것 이 Group 또한 10개가 넘어가면 오류가 발생하니 주의! 2023. 8. 5.
[SwiftUI] ScrollView 사용법 스크롤뷰 command + 클릭해보면 Show Quick Help라는 유용한 기능이 있음! View를 상속받으며, 디폴드값은 .vertical로 이것은 아래위 스크롤이다. ScrollView(.horizontal)을 이용해 가로 스크롤또한 사용할 수 있다. 현재 사용한 코드는 가로와 세로 모두 스크롤이 가능 2023. 8. 5.
[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.
[SwiftUI] 버튼을 함수로 리턴하기 func buildButton(parameter : Parameter) -> Button버튼 함수의 형식 func buildButton() -> Button { return Button { } label: { Text("첫번째 버튼입니다.") } }이런식으로 label 내 요소가 존재한다면 안에 표시해주어야함 2023. 6. 26.
[UIkit] 음성출력예제 let speechSynth = AVSpeechSynthesizer() @IBAction func sayName(_ sender: Any) { //UI요소 let name: String = nameField.text ?? "" let message: String = "안녕하세요, \(name)님" helloLabel.text = message var utterance = AVSpeechUtterance(string: message) speechSynth.speak(utterance) } 2023. 6. 12.
[Swift] 기초 예제 5 (딕셔너리) //code1 var team = ["김윤","김찬","송성","윤영","정혜"] for i in team { print("\(i)") } //code2 var team = ["김윤","김찬","송성","윤영","정혜"] var nextTeam = ["이수","손윤","이제","박채","김하"] var addTeam = team+nextTeam for i in addTeam{ print("\(i)") } //code3 var teams : [String:String] = [ "김윤":"뉴진스", "김찬":"아이유", "송성":"윤성욱", "윤영":"10cm", "정혜":"장원영" ] for (key,value) in teams{ print("\(key):\(value)") } //code4 var tea.. 2023. 6. 8.