Latest 1.0.0
Homepage https://github.com/cs-joao-souza/JPAlertController
License MIT
Platforms ios 9.0
Authors

JPAlertController is Swift alert all customizable. It’s usage look like UIAlertController usage.

Using JPAlertController you can customize every text in your alert just sending some options in the constructor.

Screenshots

ScreenShot
ScreenShot

Requirements

  • iOS 9.0+
  • Xcode 8.1+
  • Swift 3.0+

Usage

It’s usage is very similar to UIAlertController. The difference is that is possible to pass options to configure your text as you want. These options need to be NSAttributedString attributes. So is possible to use:

  • NSFontAttributeName
  • NSParagraphStyleAttributeName
  • NSForegroundColorAttributeName
  • NSBackgroundColorAttributeName
  • NSLigatureAttributeName
  • NSKernAttributeName
  • NSStrikethroughStyleAttributeName
  • NSUnderlineStyleAttributeName
  • NSStrokeColorAttributeName
  • NSStrokeWidthAttributeName
  • NSShadowAttributeName
  • NSTextEffectAttributeName
  • NSAttachmentAttributeName
  • NSLinkAttributeName
  • NSBaselineOffsetAttributeName
  • NSBaselineOffsetAttributeName

  • and so on.
let titleOptions = [ NSFontAttributeName: UIFont(name: "Chalkduster", size: 18.0)!, NSForegroundColorAttributeName: UIColor.blue ]

let messageOptions = [ NSFontAttributeName: UIFont(name: "Chalkduster", size: 14.0)!, NSForegroundColorAttributeName: UIColor.red ]

let alert = JPAlertController(title: "Alert", message: "This is a customizable Alert", titleOptions: titleOptions, messageOptions: messageOptions)

let okAction = JPAlertAction(title: "OK", titleOptions: titleOptions) { action in
    print("OK action")
}

alert.addAction(action: okAction)

let cancelOptions = [ NSFontAttributeName: UIFont(name: "Chalkduster", size: 14.0)!, NSForegroundColorAttributeName: UIColor.red ]

let cancelAction = JPAlertAction(title: "Cancel", titleOptions: cancelOptions) { action in
  print("Cancel action")
}

alert.addAction(action: cancelAction)

self.present(alert, animated: true, completion: nil)

Installation

Cocoapods

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

pod 'JPAlertController'

Manual

Just copy and paste the files inside source code folder into your project.

Todo

  • Add separators
  • Let it be able to customize the background
  • Let it be able to customize the viewController’s background

License

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

Latest podspec

{
    "name": "JPAlertController",
    "version": "1.0.0",
    "summary": "An AlertController all customizable written in Swift 3.",
    "description": ""An AlertController all customizable written in Swift 3."",
    "homepage": "https://github.com/cs-joao-souza/JPAlertController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "cs-joao-souza": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/cs-joao-souza/JPAlertController.git",
        "tag": "1.0.0"
    },
    "source_files": "JPAlertController/Source Code/*.swift",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This