Latest 3.0.0
Homepage https://github.com/cp3hnu/CPAlertViewController
License MIT
Platforms ios 8.0, requires ARC
Authors

CPAlertViewController is custom Alert View Controller written in Swift.

Inspired by the excellent SweetAlert-iOS and SCLAlertView-Swift. The difference is that CPAlertViewController uses auto layout.

Screenshot

CPAlertViewController

Installation

Manually

The simplest way to install this library is to copy Classes/*.swift to your project.

CocoaPods

You can also install this library using CocoaPods. Just add this line to your Podfile:

pod 'CPAlertViewController'

Then import library module like so:

import CPAlertViewController

Carthage

github "cp3hnu/CPAlertViewController"
  • Drag and drop CPAlertViewController.framework from /Carthage/Build/iOS/ to Linked frameworks and libraries in Xcode (Project>Target>General>Linked frameworks and libraries)

  • Add new run script

    /usr/local/bin/carthage copy-frameworks
  • Add Input files $(SRCROOT)/Carthage/Build/iOS/CPAlertViewController.framework

Properties

These properties is global and applied to the whole project.

/// The font size of tittle
public static var titleFontSize: CGFloat = 22.0

/// The font size of message
public static var messageFontSize: CGFloat = 16.0

/// The font size of button
public static var buttonFontSize: CGFloat = 16.0

/// The text color of tittle
public static var titleColor = UIColor.colorFromRGB(0x333333)

/// The text color of message
public static var messageColor = UIColor.colorFromRGB(0x555555)

/// The text color of button
public static var buttonTitleColor = UIColor.whiteColor()

/// The normal background color of button
public static var buttonBGNormalColor = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)

/// The highlighted background color of button
public static var buttonBGHighlightedColor = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 0.7)

Usage

The designated method

public func show(title title: String?, message: String?, style: CPAlertStyle = .None, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

CPAlertViewController also provides four convenience methods

Show success

public func showSuccess(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil) 

Show error

public func showError(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

Show warning

public func showWarning(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

Show info

public func showInfo(title title: String?, message: String?, buttonTitle: String = "OK", otherButtonTitle: String? = nil, action: UserAction? = nil)

Requirements

  • Swift 3.0+

  • Xcode 8.0+

TO DO

License

Released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "CPAlertViewController",
    "version": "3.0.0",
    "summary": "CPAlertViewController is custom animated Alert View Controller. Written in Swift.",
    "homepage": "https://github.com/cp3hnu/CPAlertViewController",
    "license": "MIT",
    "authors": {
        "Wei Zhao": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cp3hnu/CPAlertViewController.git",
        "tag": "3.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Classes/*.swift"
}

Pin It on Pinterest

Share This