Giter Club home page Giter Club logo

doalertcontroller's Introduction

DOAlertController

Simple Alert View written in Swift, which can be used as a UIAlertController replacement.
It supports from iOS7! It is simple and easily customizable!

BackgroundImage BackgroundImage

Easy to use

DOAlertController can be used as a UIAlertController.

// Set title, message and alert style
let alertController = DOAlertController(title: "title", message: "message", preferredStyle: .Alert)

// Create the action.
let cancelAction = DOAlertAction(title: "Cancel", style: .Cancel, handler: nil)

// You can add plural action.
let okAction = DOAlertAction(title: "OK" style: .Default) { action in
    NSLog("OK action occured.")
}

// Add the action.
alertController.addAction(cancelAction)
alertController.addAction(okAction)

// Show alert
presentViewController(alertController, animated: true, completion: nil)

Customize

  • add TextField (Alert style only)
  • change Fonts
  • change color (Overlay, View, Text, Buttons)

BackgroundImage BackgroundImage

Add TextField

alertController.addTextFieldWithConfigurationHandler { textField in
    // text field(UITextField) setting
    // ex) textField.placeholder = "Password"
    //     textField.secureTextEntry = true
}

Change Design

Overlay color
alertController.overlayColor = UIColor(red:235/255, green:245/255, blue:255/255, alpha:0.7)
Background color
alertController.alertViewBgColor = UIColor(red:44/255, green:62/255, blue:80/255, alpha:1)
Title (font, text color)
alertController.titleFont = UIFont(name: "GillSans-Bold", size: 18.0)
alertController.titleTextColor = UIColor(red:241/255, green:196/255, blue:15/255, alpha:1)
Message (font, text color)
alertController.messageFont = UIFont(name: "GillSans-Italic", size: 15.0)
alertController.messageTextColor = UIColor.whiteColor()
Button (font, text color, background color(default/highlighted))
alertController.buttonFont[.Default] = UIFont(name: "GillSans-Bold", size: 16.0)
alertController.buttonTextColor[.Default] = UIColor(red:44/255, green:62/255, blue:80/255, alpha:1)
alertController.buttonBgColor[.Default] = UIColor(red: 46/255, green:204/255, blue:113/255, alpha:1)
alertController.buttonBgColorHighlighted[.Default] = UIColor(red:64/255, green:212/255, blue:126/255, alpha:1)
// Default style : [.Default]
// Cancel style : [.Default] → [.Cancel]
// Destructive style : [.Default] → [.Destructive]

Installation

DOAlertController is available through CocoaPods.

To install add the following line to your Podfile:

pod 'DOAlertController'

License

This software is released under the MIT License, see LICENSE.txt.

doalertcontroller's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doalertcontroller's Issues

Support for new versions of swift

The repo is outdated now, Can you please accept the pull requests or provide an up-to-date version?

Thank you for your time and effort

Cannot show another view controller by pressing button

It's a nice and easy library for alert controller.
However, I have a question.

In my program, as I press the button, I want to show another view controller. So I use "performSegue" to do that. It works on UIAlertController.
When I change to DOAlertController, the view didn't show up, but the code which I write in that view controller still appear in log. (It still prints what I want to show).

The error message is:
Warning: Attempt to present <XXX.AnotherViewController: 0x101933400> on <DOAlertController: 0x101928a00> whose view is not in the window hierarchy!

I'm wondering if somebody can give me some directions, thanks a lot. :-)

fatal error: Array index out of range on actionsheet on tap gesture

I have an array of 5, cancelButtonTag is 6, hence fatal error: Array index out of range

// Handle ContainerView tap gesture
func handleContainerViewTapGesture(sender: AnyObject) {
// cancel action
let action = actions[cancelButtonTag] as! DOAlertAction
if (action.handler != nil) {
action.handler(action)
}
self.dismissViewControllerAnimated(true, completion: nil)
}

error

let error: NSError?
NSException.raise("NSInternalInconsistencyException", format:"DOAlertController can only have one action with a style of DOAlertActionStyleCancel", arguments:getVaList([error ?? "nil"]))

→ DOAlertController.swift:714:189: Constant 'error' used before being initialized

Please fix it, thank you

Swift3

it'd be cool to have a swift 3 version, if you have any interest to create a branch i would like to help with that.

Orientation

The alert seems to ignore supportedInterfaceOrientations, meaning that view controllers that are locked to Landscape can rotate to Portrait when the alert is shown. Very annoying problem.

Swift 4

its an awesome library but can you update it to swift 4? its very bad that we manually need to fix the errors and then when we do pod install or update to get another library we lose every change.

thanks!

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.