Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

create alert in swift

class ViewController: UIViewController {

    @IBAction func showAlertButtonTapped(_ sender: UIButton) {

        // create the alert
        let alert = UIAlertController(title: "My Title", message: "This is my message.", preferredStyle: .alert)

        // add an action (button)
        alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))

        // show the alert
        self.present(alert, animated: true, completion: nil)
    }
}
Comment

alert swiftUI

@State private var showingAlert = false

Button("Show Alert") {
            showingAlert = true
        }
        .alert("Important message", isPresented: $showingAlert) {
            Button("OK", role: .cancel) { }
        }
Comment

PREVIOUS NEXT
Code Example
Swift :: swift read file 
Swift :: power number in swift 
Swift :: swift post request 
Swift :: how to bold text swiftui 
Swift :: swift round double to 2 decimal places 
Swift :: how to change background color of ui button swift 
Swift :: swift enum 
Swift :: sort array alphabetically swift 4 
Swift :: tableview cell animation swift 
Swift :: swift uitableview insert cell 
Swift :: try? as? in swiftui 
Swift :: swift guard let 
Swift :: uibutton swift set title color 
Swift :: How to hide view in swiftui 
Swift :: how to change background color of stackview swift 
Swift :: symfony swiftmailer 
Swift :: uilabel set fon siz 
Swift :: swift get file size from url 
Swift :: === in swift 
Swift :: sort list ios swift 
Swift :: swift ui view 
Swift :: convert nscfstring to dictionary swift 
Swift :: after redirect from another viewcontroller in swift 5 make full view view controller 
Swift :: check google ads sdk version swift 
Swift :: how to check if something is in a set in swift 
Swift :: swift hmac256 
Swift :: single word search swift 
Swift :: Swift Find Number of Set Elements 
Swift :: ios uikit hide/show keyboard if scrolling 
Swift :: property observer in swift 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =