Coder Social home page Coder Social logo

ajunlonglive / sclalertview-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vikmeup/sclalertview-swift

0.0 3.0 0.0 2.08 MB

Beautiful animated Alert View. Written in Swift

License: MIT License

Swift 77.50% Ruby 0.82% Objective-C 12.17% C 0.20% Makefile 9.32%

sclalertview-swift's Introduction

SCLAlertView

Animated Alert View written in Swift, which can be used as a UIAlertView or UIAlertController replacement. Since UIAlertView is deprecated and UIAlertController only works on iOS 8.x or above, if you have a Swift project where you want to support iOS 7.x too, SCLAlertView is an ideal substitution.

BackgroundImage_ BackgroundImage

Easy to use

Get Started

// Get started
SCLAlertView().showInfo("Important info", subTitle: "You are great")

Updating the alert view

let alertViewResponder: SCLAlertViewResponder = SCLAlertView().showSuccess("Hello World", subTitle: "This is a more descriptive text.")

// Upon displaying, change/close view
alertViewResponder.setTitle("New Title") // Rename title
alertViewResponder.setSubTitle("New description") // Rename subtitle
alertViewResponder.close() // Close view

Alternative alert types

SCLAlertView().showError("Hello Error", subTitle: "This is a more descriptive error text.") // Error
SCLAlertView().showNotice("Hello Notice", subTitle: "This is a more descriptive notice text.") // Notice
SCLAlertView().showWarning("Hello Warning", subTitle: "This is a more descriptive warning text.") // Warning
SCLAlertView().showInfo("Hello Info", subTitle: "This is a more descriptive info text.") // Info
SCLAlertView().showEdit("Hello Edit", subTitle: "This is a more descriptive info text.") // Edit

Raw call to showTitle()

SCLAlertView().showTitle(
    title: "Congratulations", // Title of view
    subTitle: "Operation successfully completed.", // String of view
    duration: 2.0, // Duration to show before closing automatically, default: 0.0
    completeText: "Done", // Optional button value, default: ""
    style: .Success // Styles - see below.
    colorStyle: 0xA429FF,
    colorTextButton: 0xFFFFFF
)

Controls

Add buttons

let alertView = SCLAlertView()
alertView.addButton("First Button", target:self, selector:Selector("firstButton"))
alertView.addButton("Second Button") {
    println("Second button tapped")
}
alertView.showSuccess("Button View", subTitle: "This alert view has buttons")

Hide default close button

let alertView = SCLAlertView()
alertView.showCloseButton = false
alertView.showSuccess("No button", subTitle: "You will have hard times trying to close me")

Add Text fields

// Add a text field
let alert = SCLAlertView()
let txt = alert.addTextField(title:"Enter your name")
alert.addButton("Show Name") {
    println("Text value: \(txt.text)")
}
alert.showEdit("Edit View", subTitle: "This alert view shows a text box")

Alert View Styles

enum SCLAlertViewStyle: Int {
    case Success, Error, Notice, Warning, Info, Edit, Wait
}

Installation

SCLAlertView is available through CocoaPods.

To install add the following line to your Podfile:

pod 'SCLAlertView'

Collaboration

I tried to build an easy to use API, while beeing flexible enough for multiple variations, but I'm sure there are ways of improving and adding more features, so feel free to collaborate with ideas, issues and/or pull requests.

Incoming improvements

  • More animations
  • Performance tests

Has been developed initially for the Scroll Feed app

sclalertview-swift's People

Contributors

vikmeup avatar fahimf avatar aymenworks avatar alec-c4 avatar frantzmiccoli avatar kee23 avatar pgmy avatar dsxniubility avatar lingtorp avatar joseph-montanez avatar kam800 avatar ncerezo avatar ssut avatar dodo-rk avatar calvinchengx avatar orangecoding avatar subicura avatar jeremyvoss avatar ken0nek avatar yizhiheng avatar ntanyeri avatar philipheinser avatar freddy-dev avatar

Watchers

James Cloos avatar  avatar  avatar

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.