new

NewYorkAlert

🗽A modern alert and action sheet for iOS written in Swift.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

65

Maintenance

Last Commit

1yr ago

Contributors

1

Package

Dependencies

0

License

MIT

Categories

Readme

Logo

A modern alert and action sheet for iOS written in Swift.

Swift Version Version License Platform Carthage compatible SPM compatible

Introduction

NewYorkAlert is a modern alert and action sheet for iOS written in Swift.

AlertActionSheetTextFieldsDarkMode

Features

  • Modern design
  • Easy to add text fields and image
  • Support dark mode
  • Can be dismissed via background tap

Requirements

  • Swift 5.1
  • iOS 11.0 or later

Usage

API Documentation

Default Alert

let alert = NewYorkAlertController(title: "Title", message: "Message", style: .alert)

let ok = NewYorkButton(title: "OK", style: .default) { _ in
    print("Tapped OK")
}
let cancel = NewYorkButton(title: "Cancel", style: .cancel)

alert.addButton(ok)
alert.addButton(cancel)

present(alert, animated: true)

Default Action Sheet

let actionSheet = NewYorkAlertController(title: "Title", message: "Message", style: .actionSheet)

let buttons = [
    NewYorkButton(title: "Apple", style: .default),
    NewYorkButton(title: "Orange", style: .default),
    NewYorkButton(title: "Lemon", style: .default),
]
actionSheet.addButtons(buttons)

present(actionSheet, animated: true)

Text Fields (Only Alert)

let alert = NewYorkAlertController.init(title: "Title", message: "Message", style: .alert)

alert.addTextField { tf in
    tf.placeholder = "username"
    tf.tag = 1
}
alert.addTextField { tf in
    tf.placeholder = "password"
    tf.tag = 2
}

let ok = NewYorkButton(title: "OK", style: .default) { [unowned alert] _ in
    alert.textFields.forEach { tf in
        let text = tf.text ?? ""
        switch tf.tag {
        case 1:
            print("username: \(text)")
        case 2:
            print("password: \(text)")
        default:
            break
        }
    }
}
let cancel = NewYorkButton(title: "Cancel", style: .cancel)
alert.addButtons([ok, cancel])

present(alert, animated: true)

Dark Mode

NewYorkAlert will automatically follow an app's user interface style.

AlertActionSheetTextFields

Installation

CocoaPods

Add the following to your Podfile:

pod 'NewYorkAlert'

Carthage

Add the following to your Cartfile:

github "shiba1014/NewYorkAlert"

Swift Package Manager

Select File > Swift Packages > Add Package Dependency, and enter the following:

https://github.com/shiba1014/NewYorkAlert

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100