Coder Social home page Coder Social logo

evwdropdownnotification's Introduction

EVWDropDownNotification

A simple but yet powerful Swift Dropdown Notification for iOS inspired by AlvaroFranco but rewritten in Swift 2.2 and extended to offer much more customisation

Version License Platform

Example 1

Features

  • Written in Swift 2.2
  • Customisable Button Alignment (Top, Bottom)
  • Customisable Button Parameters (e.g. Corner Radius, Border Color & Width)
  • Customisable Button Dipslay (only Top, only Bottom, Both)
  • Customisable Icon
  • Customisable Independent Text Color & Size for Title and Subtitle
  • Customisable Background Color or Blur Effect
  • Customisable TapToDismiss Delegate
  • Customisable Animation

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Requires iOS SDK version > 8.0

Installation

EVWDropDownNotification is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "EVWDropDownNotification"

Usage

First import the "EVWDropDownNotification" module:

import EVWDropDownNotification

Then extend your ViewController with the "EVWDropDownNotificationDelegate" and initialise a class variable of type "EVWDropDownNotification":

class ViewController: UIViewController, EVWDropDownNotificationDelegate {

let notification = EVWDropDownNotification()
...

Implement the 3 Delegate Methods:

func dropdownNotificationBottomButtonTapped() {
  //Do something
  ...
  //Dismiss the notification view
  notification.dismissWithGravityAnimation(true)
}
    
func dropdownNotificationTopButtonTapped() {
  //Do something
  ...
  //Dismiss the notification view
  notification.dismissWithGravityAnimation(true)
}
    
func dropdownNotificationDismissedWithTap() {
  //Do something
  ...
  // !!!!! NO NEED TO DISMISS THE NOTIFICATION VIEW !!!!!
}

In your ViewDidLoad set the Properties for the Notification (see below for all available properties):

  notification.delegate = self
  notification.image = UIImage(named: "notification")
  notification.bottomButtonText = "Accept"
  notification.topButtonText = "Cancel"
  notification.dismissOnTap = false
  notification.buttonVerticalAligment = .Bottom
  notification.titleText = "Title Here"
  notification.subtitleText = "Message Here" 

Once all properties set, call the following function to display the Notfication:

 /*
 * NOTE: always provide the ViewController (self.view.Superview) as first parameter
 */
 notification.presentInView(self.view.superview!, withGravityAnimation: true)

Properties

The following public properties are available, please note that some are required and some other are optional because default values have been set:

Required

The only two mandatory properties are the Title and Subtitle of the Notification

  /*
  * Title Attributes
  */
  
  public var titleText:String?
    
  /*
  * Subtitle Attributes
  */
  
  public var subtitleText:String?

Optional

All properties below are optional. !! Note that Buttons will only be displayed if the buttonText is provided !!

  /*
  * Padding between elements
  */
  
  public var paddingBetweenElements:CGFloat = 10
    
  /*
  * Background Color If set, it overwrites the blur effect
  */
  
  public var backgroundColor:UIColor?
    
  /*
  * Title Properties
  */
  
  public var titleLabelFontSize:CGFloat = 19
  public var titleLabelColor:UIColor = UIColor.blackColor()
    
  /*
  * Subtitle Propperties
  */
  
  public var subTitleLabelFontSize:CGFloat = 14
  public var subTitleLabelColor:UIColor = UIColor.blackColor()
    
  /*
  * General Button Properties
  */
  
  public var buttonFontSize:CGFloat = 13
  public var buttonCornerRadius:CGFloat = 10
  public var buttonBorderWidth:CGFloat = 1
  public var buttonBorderColor:UIColor = UIColor.blackColor()
  public var buttonWidth:CGFloat = 75
  public var buttonHeight:CGFloat = 30
  public var buttonVerticalAligment:ButtonPosition = .Bottom
    
  /*
  * Top Button Properties
  */
  
  public var topButtonTextColor:UIColor = UIColor.blackColor()
  public var topButtonBackgroundColor:UIColor = UIColor.clearColor()
    
    
  /*
  * Bottom Button Properties
  */
  
  public var bottomButtonTextColor:UIColor = UIColor.blackColor()
  public var bottomButtonBackgroundColor:UIColor = UIColor.clearColor()
    
  /*
  * Icon Properties -> Size is squared
  */
  
  public var imageSquaredSize:CGFloat = 40
  public var image:UIImage?
    
    
  /*
  * Dismiss On Tap
  */
  
  public var dismissOnTap:Bool = false

Author

CRE8IT GmbH, Switzerland

License

EVWDropDownNotification is available under the MIT license. See the LICENSE file for more info.

evwdropdownnotification's People

Watchers

 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.