//
//  ContentView.swift
//  Toast_popup_tutorial
//
//  Created by devdepot on 2021/04/28.
//

import SwiftUI
import ExytePopupView

struct ContentView: View {
    @State  var shouldShowToast: Bool = false;
    
    
    func creatTopeSolidMessage() -> some View{
        Text("토스트 메세지입니다.")
            .padding()
            .foregroundColor(Color.white)
            .background(Color.blue)
            .cornerRadius(10)
    }
    
    var body: some View {
        
        ZStack{
            VStack{
                Button(action: {
                    self.shouldShowToast = true
                }, label: {
                    Text("토스트 띄우기")
                        .font(.system(size: 25))
                        .foregroundColor(Color.white)
                        .padding()
                        .background(Color.blue)
                        .cornerRadius(10)
                })
            }
        }
        .popup(isPresented: $shouldShowToast
               , type: .toast
               , position: .bottom
               , animation: .default
               , autohideIn: 2  //2초가 지난 후 자동으로 사라짐
               , closeOnTap: true
               , closeOnTapOutside: true
               , view: {
                creatTopeSolidMessage()
                
               })
            

    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

'IOS > SwiftUI' 카테고리의 다른 글

(SwiftUI)16.lazyGridView  (0) 2021.04.29
(SwiftUI)15.피커뷰  (0) 2021.04.28
(SwiftUI)13.TextField  (0) 2021.04.28
(SwiftUI)12.커스톰 탭뷰  (0) 2021.04.28
(SwiftUI)11.탭뷰  (0) 2021.04.28

+ Recent posts