티스토리 뷰

📱 SwiftUI

버튼 배경 설정

James Wetzel 2023. 5. 7. 16:07
728x90
반응형

.background 방식

Button {
    let utterance = AVSpeechUtterance(string: word.alphabet ?? "")
    utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
    DoctorSLApp.avSpeechSynthesizer.speak(utterance)
} label: {
    Image(systemName: "speaker.wave.3")
        .foregroundColor(.accentColor)
        .frame(width: 50, height: 50, alignment: .center)
        .background(.ultraThinMaterial, in: Circle())
}

 

.clipShape 방식

Button {
    let utterance = AVSpeechUtterance(string: word.alphabet ?? "")
    utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
    DoctorSLApp.avSpeechSynthesizer.speak(utterance)
} label: {
    Image(systemName: "speaker.wave.3")
        .foregroundColor(.accentColor)
        .frame(width: 50, height: 50, alignment: .center)
        .background(.red)
        .clipShape(RoundedRectangle(cornerRadius: 10))
}

 

728x90
반응형