CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

WSAlertController 0.0.2

WSAlertController 0.0.2

Maintained by Zev.



  • By
  • zevwings

WSAlertController

a custom swift alert controller

Carthage compatible CocoaPods Compatible Platform

WSAlertController is a pure-swift and wieldy AlertController.

Requirements

  • iOS 9.0+
  • Swift 5.0

Installation

Cocoapod

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.

You can install Cocoapod with the following command

$ sudo gem install cocoapods

To integrate WSAlertController into your project using CocoaPods, specify it into your Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
    use_frameworks!
    pod 'WSAlertController'
end

Then,install your dependencies with CocoaPods.

$ pod install

Carthage

Carthage is intended to be the simplest way to add frameworks to your application.

You can install Carthage with Homebrew using following command:

$ brew update
$ brew install carthage

To integrate WSAlertController into your project using Carthage, specify it into your Cartfile

github "zevwings/WSAlertController" ~> 0.0.1

Then,build the framework with Carthage using carthage update and drag WSAlertController.framework into your project.

Note:

The framework is under the Carthage/Build, and you should drag it into Target -> Genral -> Embedded Binaries

Usage

You can use import WSAlertController when you needed to use WSAlertController.

Showing a Alert

When you start a task, You can using following code:

let alertController = WSAlertController(title: "title", message: "message")
present(alertController, animated: true, completion: nil)

you can add alert action use:

alertController.addAction(WSAlertAction(title: "confirm", style: .default, handler: { _ in
    print("comfirm action")
}))

you can also use NSAttributedString in message body

let attributedString = NSMutableAttributedString(string: "message")
attributedString.addAttributes([.foregroundColor: UIColor.cyan], range: NSRange(location: 0, length: 4))
let alertController = WSAlertController(title: "title", message: attributedString)

Props

the following props can custom the alertController.

public var dismissHandler: DismissHandler?
public var shouldShowDismissButton: Bool = true

public var tintColor: UIColor = .blue
public var positiveColor: UIColor = Constant.positiveColor
public var negativeColor: UIColor = Constant.negativeColor
public var buttonFont: UIFont = .systemFont(ofSize: 14.0)

public var titleColor: UIColor = Constant.titleColor
public var titleFont: UIFont = .systemFont(ofSize: 14.0)

public var messageColor: UIColor = Constant.messageColor
public var messageFont: UIFont = .systemFont(ofSize: 14.0)

License

WSAlertAction distributed under the terms and conditions of the Apache License