Git Product home page Git Product logo

akalertcontroller's Introduction

AKAlertController

Version Platform License

Simple Alert View written in Swift, which can be used as a UIAlertController replacement.
It supports from iOS 10! It is simple and easily customizable! Supported alerts and action sheets!

BackgroundImage BackgroundImage BackgroundImage

Easy to use

AKAlertController can be used as a UIAlertController.

Alert

let alertController = AKAlertController(title: "Title label", message: "Message label", preferredStyle: .alert)
let handler: (AKAlertAction) -> Void = { action in print("\(action.title) pressed" )}

alertController.addAction(AKAlertAction(title: "Default action", style: .default, handler: handler))
alertController.addAction(AKAlertAction(title: "Cancel action", style: .cancel, handler: handler))
alertController.addAction(AKAlertAction(title: "Destructive action", style: .destructive, handler: handler))

// add textfield
alertController.addTextFieldWithConfigurationHandler { textField in
  textField.placeholder = "Password"
  textField.secureTextEntry = true
}

present(alertController, animated: true, completion: nil)

Action sheet

let actionSheet = AKAlertController(title: "Title label", message: nil, preferredStyle: .actionSheet)
let handler: (AKAlertAction) -> Void = { action in print("\(action.title) pressed" )}

actionSheet.addAction(AKAlertAction(title: "Default action", style: .default, handler: handler))
actionSheet.addAction(AKAlertAction(title: "Cancel action", style: .cancel, handler: handler))
actionSheet.addAction(AKAlertAction(title: "Destructive action", style: .destructive, handler: handler))

present(actionSheet, animated: true, completion: nil)

Сustomizable elements

AKAlertControlle completely repeats the system UIAlertController interface, but with the ability to customize:

  • Fonts (Text, Buttons)
  • Colors (Overlay, Views, Text, Buttons)
  • Sizes
  • It is possible to add an image

BackgroundImage BackgroundImage

Customization is available as at the controller level

var appearance = AKAlertControllerAppearance.defaultAppearance()
appearance.titleFont = .systemFont(ofSize: 22)
appearance.titleTextColor = .purple

let alertController = AKAlertController(title: "Title", message: "Message", preferredStyle: .alert, appearance: appearance)
...

... so for every action

...
let cancelAction = AKAlertAction(title: "Cancel", style: .cancel, handler: handler)
cancelAction.bgColor = .black
cancelAction.textColor = .white
cancelAction.icon = UIImage(named: "close")
alertController.addAction(cancelAction)
...

Example with image

let alertController = AKAlertController(title: "Title label", message: "Message label", headerImage: UIImage(named: "close"), preferredStyle: .alert)
let handler: (AKAlertAction) -> Void = { action in print("\(action.title) pressed" )}
alertController.addAction(AKAlertAction(title: "Default action", style: .default, handler: handler))
alertController.addAction(AKAlertAction(title: "Cancel action", style: .cancel, handler: handler))
alertController.addAction(AKAlertAction(title: "Destructive action", style: .destructive, handler: handler))
present(alertController, animated: true, completion: nil)

BackgroundImage BackgroundImage

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 10.0+
  • Swift 5.0+
  • Xcode 11+

Installation

AKAlertController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AKAlertController', '~> 1.1.1'

License

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

akalertcontroller's People

Contributors

akaraul avatar

Stargazers

 avatar Vitaly Timofeev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.