Giter Club home page Giter Club logo

swiftynotifications's Introduction

Build Status CocoaPods Compatible Carthage Compatible Coverage Status Platform License

SwiftyNotifications

Highly configurable iOS UIView for presenting notifications that doesn't block the UI.

Screenshots

info error success warning custom

Requirements

SwiftyNotifications Version Minimum iOS Target Swift Version
0.5.2 9.0 4.1
0.5.1 8.0 4.0
0.4 8.0 3.x

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate SwiftyNotifications into your Xcode project using CocoaPods, specify it in your Podfile:

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

target '<Your Target Name>' do
	pod 'SwiftyNotifications', '~>0.5.2'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

brew update
brew install carthage

To integrate SwiftyNotifications into your Xcode project using Carthage, specify it in your Cartfile:

github "abdullahselek/SwiftyNotifications" ~> 0.5.2

Example Usage

import SwiftyNotifications

Than initiate notification and add to your view

let notification = SwiftyNotifications.withStyle(style: .info,
                                                 title: "Swifty Notifications",
                                                 subtitle: "Highly configurable iOS UIView for presenting notifications that doesn't block the UI",
                                                 direction: .bottom)
view.addSubview(notification)

You can customize this notification anytime in your view

notification.customize(style: .warning)

and update texts

notification.setTitle(title: "New title", subtitle: "New subtitle")

To show the notification

notification.show()

To dismiss

notification.dismiss()

Creating custom notification

let customNotification = SwiftyNotifications.withStyle(style: .custom,
                                                       title: "Custom",
                                                       subtitle: "Custom notification with custom image and colors",
                                                       direction: .top)
customNotification.leftAccessoryView.image = UIImage(named: "apple_logo")!
customNotification.setCustomColors(backgroundColor: UIColor.cyan, textColor: UIColor.white)
view.addSubview(customNotification)

Other available functions for creating notifications

With a time interval option for auto dismissing

let notification = SwiftyNotifications.withStyle(style: .warning,
                                                 title: "Title",
                                                 subtitle: "Subtitle",
                                                 dismissDelay: 3.0,
                                                 direction: .top)

With touch handler

let notification = SwiftyNotifications.withStyle(style: .error,
                                                 title: "Title",
                                                 subtitle: "Subtitle",
                                                 dismissDelay: 5.0,
                                                 direction: .bottom) {
                                                            
        }

New class added for just displaying message

let swiftyNotificationsMessage = SwiftyNotificationsMessage.withBackgroundColor(color: UIColor.darkGray,
                                                                                message: "Notification with just text",
                                                                                direction: .top)
view.addSubview(swiftyNotificationsMessage)

To display message notification

swiftyNotificationsMessage.show()

Dismissing message notification

swiftyNotificationsMessage.dismiss()

Optional delegates that gives informations about showing and dismissing notification screen

  • func willShowNotification(notification: SwiftyNotifications)
  • func didShowNotification(notification: SwiftyNotifications)
  • func willDismissNotification(notification: SwiftyNotifications)
  • func didDismissNotification(notification: SwiftyNotifications)

Adding touch handler to catch tap gestures on notification

notification.addTouchHandler {

        }

Add a swipe gesture recognizer to dismiss notification with a swipe direction

notification.addSwipeGestureRecognizer(direction: .down)

Possible swipe directions

  • right
  • left
  • up
  • down

swiftynotifications's People

Contributors

abdullahselek avatar tobaloidee avatar bastianschilbe avatar

Watchers

James Cloos 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.