Coder Social home page Coder Social logo

yippeeapp / swift-prompts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gabrielalva/swift-prompts

0.0 2.0 0.0 46.05 MB

A Swift library to design custom prompts with a great scope of options to choose from.

License: Other

Swift 98.88% Ruby 1.12%

swift-prompts's Introduction

License Pod Version Pod Platform Pod License

Swift Prompts.

Installation

CocoaPods

Install with CocoaPods by adding the following to your Podfile:

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

use_frameworks!

pod 'Swift-Prompts', '~> 1.0.0'

Note: We follow http://semver.org for versioning the public API.

Manually

  • Just include the three .swift files found on the Swift Prompts folder on the demo Xcode project.

Usage

Using Swift Prompts is very simple and fast.

Adopting the prompt's delegate

In your class declaration, after specifying the type of class write SwiftPromptsProtocol as shown here:

class ViewController: UIViewController,  SwiftPromptsProtocol

Now, depending on the type of prompt, you can use any of the optional delegate functions

func clickedOnTheMainButton() {}
func clickedOnTheSecondButton() {}
func promptWasDismissed() {}

Displaying a prompt

First you need to declare a var outside of a function:

var prompt = SwiftPromptsView()

Next, where you would like to trigger the prompt (e.g. in the action function of a button):

prompt = SwiftPromptsView(frame: self.view.bounds)
prompt.delegate = self

//Customization

self.view.addSubview(prompt)

Dismissing a prompt

To dismiss the prompt, you can write this line in one of the delegate functions or in a different one:

prompt.dismissPrompt()

Alternatively, the dismissal by gesture is enabled by default so you can dismiss a prompt by moving it up or down until it dims completely. Dismissal by gesture will trigger the promptWasDismissed() delegate function.

##Customization

Once you have your assigned the frame and delegate, you can customize the look and feel of your prompt and its background. You can customize almost every aspect of it as shown above including the width and height. The demo app is well documented for you to use any function of the customization API. To see the full list you can navigate to the SwiftPromptsView class and look for the API pragma mark.

##Example

You can find a full example on usage and customization on the Xcode project attached to this repository.

License

Source code of this project is available under the standard MIT license. Please have a look at the license file.

swift-prompts's People

Contributors

gabrielalva avatar gnatok avatar hons82 avatar jchomali avatar liebeskind avatar

Watchers

Chew Chit Siang 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.