Skip to content
/ MSAlert Public

Simple and super easy to use of native UIAlertController

License

Notifications You must be signed in to change notification settings

MaorS/MSAlert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MSAlert

Simple and super easy to use of native UIAlertController

Installation

Manually

Drag and drop MSAction.swift and Assets into your project

Usage

Initializate MSAlert object

Empty MSAlert object

MSAlert(viewController: self, sourceView: sender)

Or with title and message

MSAlert(viewController: self, sourceView: sender, title: "Your Title", message: "Your message")

Add alert actions

Simple alert action from MSActionType enum

.add(.ok)

Custom alert action title

.add(.cancel, title: "custom title")

Custom alert action style

.add(.cancel, title: "custom title", style: .destructive)

Custom alert action image

.add(.cancel, title: "custom title", style: .destructive, image: my_image)

Use the default image of MSActionType enum

.add(.cancel, title: "custom title", style: .destructive, defaultImage : true)

Add custom alert actions

.add(title: "Accept"){
// completion on click
}

customized:

.add(title: "Accept", isDestructive: false, image: my_image){
// completion on click
}

Set alert sound

.setSound(from: myURL)

Set tint color

.setTint(color: .purple)

Show the alert

.show()

Show the alert with completion handler

.show { didPress in
  // on click of alert action

  if didPress == .ok{
    // do some
  }
}

License

MSAlert is available under the MIT license. See the LICENSE file for more info.