본문 바로가기

PROGRAMMING CODE/SWIFT68

[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.