Latest | 0.2.0 |
---|---|
Homepage | https://github.com/dhirajjadhao/Casper |
License | MIT |
Platforms | ios 9.0, requires ARC |
Dependencies | Eureka, Nuke-FLAnimatedImage-Plugin, QRCode |
Frameworks | UIKit |
Authors |
Casper is a lightweight and highly customisable framework which extends the usability of UIAlertController to provide you with much more customisable and frequently required UI elements.
Overview
Contents
Requirements
- iOS 9.0+
- Xcode 8+
- Swift 3
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1.0+ is required to build Casper.
To integrate Casper into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Casper'
end
Then, run the following command:
$ pod install
Example project
You can clone and run the Example project to see examples of most of Casper’s features.
Usage
How to create an Alert with UICasperController
import Casper
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let casperController = UICasperController(title: "Title", message: "Message", preferredStyle: UICasperControllerStyle.alert)
casperController.addAction(title: "Volume", style: UICasperActionStyle.slider, options: nil, value: nil) { (value) in
}
casperController.present(inViewController: self, animated: true, completion: nil)
}
}
Here we created an instance of casper controller and added casper controller action to it of style Slider.
You can create controller in this way and add an actions of different styles to it.
Every action comes with its handler which gets called when there is change in value.
UICasperControllerStyle
Casper supports following styles same as UIAlertController
- Alert
let casperController = UICasperController(title: "Title", message: "Message", preferredStyle: UICasperControllerStyle.alert)
- ActionSheet
let casperController = UICasperController(title: "Title", message: "Message", preferredStyle: UICasperControllerStyle.actionSheet)
UICasperActionStyle
Casper supports following Action Styles
- SwitchToggle
- Label
- Segment
- Check
- Slider
- Stepper
- TextView
- TextField
- URLField
- IntField
- PhoneField
- PasswordField
- EmailField
- ZipcodeField
- Date
- Time
- DateTime
- Button
- Activity
- QRCode
- Image
- GIFActivity
Action Catalog
Here all actions all listed with their description and with type of options they support for customisation and type of value they returns.
SwitchToggle
This adds Switch to casper.
options: nil
value: bool
Label
This adds Label to casper.
options: nil
value: String
Segment
This adds Segment control to casper.
options: Array of string option
value: String
e.g options = ["One", "Two", "Three"]
Check
This adds Check mark row to casper.
options: nil
value: Bool
Slider
This adds Slider to casper.
options: [minValue, maxValue]
value: Float
e.g options = [0, 5] where 0 is minumum value and 5 is maximum value.
Stepper
This adds Stepper to casper.
options: [minValue, maxValue, stepValue]
value: Double
e.g options = [0, 5, 0.5] where 0 is minumum value and 5 is maximum value and 0.5 is the step value.
TextView
This adds TextView to casper.
options: nil
value: String
TextField
This adds TextField to casper.
options: nil
value: String
URLField
This adds URLField to casper.
options: nil
value: URL
IntField
This adds IntField to casper.
options: nil
value: Int
PhoneField
This adds PhoneField to casper.
options: nil
value: String
PasswordField
This adds PasswordField to casper.
options: nil
value: String
EmailField
This adds EmailField to casper.
options: nil
value: String
ZipcodeField
This adds EmailField to casper.
options: nil
value: String
Date
This adds Date to casper.
options: nil
value: Date
Latest podspec
{ "name": "Casper", "platforms": { "ios": "9.0" }, "description": "Casper is a lightweight and highly customisable framework which extends the usability of UIAlertController to provide you with much more customisable and frequently required UI elements.", "summary": "Casper is a lightweight and highly customisable framework which extends the usability of UIAlertController.", "requires_arc": true, "version": "0.2.0", "license": { "type": "MIT", "file": "LICENSE" }, "authors": { "Dhiraj Jadhao": "[[email protected]" }, "homepage": "https://github.com/dhirajjadhao/Casper", "source": { "git": "https://github.com/dhirajjadhao/Casper.git", "tag": "0.2.0" }, "frameworks": "UIKit", "dependencies": { "Eureka": [ "~> 2.0.0-beta.1" ], "Nuke-FLAnimatedImage-Plugin": [], "QRCode": [] }, "source_files": "Casper/**/*.{swift}", "pushed_with_swift_version": "3.0" }
Tue, 07 Feb 2017 14:20:06 +0000