Giter VIP home page Giter VIP logo

crtoast-ios-binding's Introduction

CRToast - Xamarin iOS Binding Library

CRToast is a library that allows you to easily create notifications that appear on top of or by pushing out the status bar or navigation bar. CRToast was originally based on CWStatusBarNotification.

demo

Requirements

CRToast uses ARC and requires iOS 7.0+. Works for iPhone and iPad.

Installation

Nuget

  Install-Package Naxam.CRToast.iOS

Usage

Notifications can be created through CRToastManager's showNotificationWithOptions:completionBlock: This will queue up a notification with the options specified. You provide options for your notification in a dictionary using the keys in CRToast.h

Example

This code

NSDictionary *options = @{
                          kCRToastTextKey : @"Hello World!",
                          kCRToastTextAlignmentKey : @(NSTextAlignmentCenter),
                          kCRToastBackgroundColorKey : [UIColor redColor],
                          kCRToastAnimationInTypeKey : @(CRToastAnimationTypeGravity),
                          kCRToastAnimationOutTypeKey : @(CRToastAnimationTypeGravity),
                          kCRToastAnimationInDirectionKey : @(CRToastAnimationDirectionLeft),
                          kCRToastAnimationOutDirectionKey : @(CRToastAnimationDirectionRight)
                          };
[CRToastManager showNotificationWithOptions:options
                            completionBlock:^{
                                NSLog(@"Completed");
                            }];

Generates this

Customization

CRToast is very customizable. Taking a hint from UIStringDrawing's drawInRect:withAttributes: book, notifications are created with dictionaries filled with all their options.

Customizing Appearance

CRToast allows for setting of

  • Left aligned image

Title and Subtitle text with:

  • Text Color
  • Text Font
  • Text Alignment
  • Text Color
  • Text Shadow Color
  • Text Shadow Offset
  • Text Max Number of Lines

Customizing Animation

CRToast also allows for animation customization. This includes.

  • Animation Type (Linear, Spring or Gravity)
  • Animation Physics Coefficients (Spring Damping, Spring Initial Velocity, Gravity Magnitude)
  • Presentation Type (Slide over bars or push content out)
  • Status visibility (Status bar on top or below)
  • Direction (Enter and exit in any direction)
  • Enter, Stay on Screen and Exit Timing

Touch Interactions

CRToast allows for any notification to respond to different types of touch interactions (tap, swipe). Interaction responders can be set as defaults or on a per notification basis. The types of interactions you can set up to respond to are:

CRToastInteractionTypeSwipeUp
CRToastInteractionTypeSwipeLeft
CRToastInteractionTypeSwipeDown
CRToastInteractionTypeSwipeRight
CRToastInteractionTypeTapOnce
CRToastInteractionTypeTapTwice
CRToastInteractionTypeTwoFingerTapOnce
CRToastInteractionTypeTwoFingerTapTwice

There are also wild card interaction types which cover a range of interactions

CRToastInteractionTypeSwipe
CRToastInteractionTypeTap
CRToastInteractionTypeAll

Any interaction can be responded to using a CRToastInteractionResponder, they can be made with the following constructor

+ (instancetype)interactionResponderWithInteractionType:(CRToastInteractionType)interactionType
                                   automaticallyDismiss:(BOOL)automaticallyDismiss
                                                  block:(void (^)(CRToastInteractionType interactionType))block;

You can set a collection of CRToastInteractionResponders as the object for the key kCRToastInteractionRespondersKey in defaults to have all notifications respond to a certain interaction, or on any given one to have the interaction responders just work for that one notification.

Persistent and Programmatically Dismissed Notifications

You can also dismiss the current notification at any time with

+ (void)dismissNotification:(BOOL)animated;

You can present notifications that must be dismissed by the user by passing @(DBL_MAX) for kCRToastTimeIntervalKey and setting up an interaction responder that will dismiss the notification.

Setting Defaults

There are sane defaults set for all properties, however you can set a default set of options for your application's notifications using CRToastManagers's setDefaultOptions:.

crtoast-ios-binding's People

Contributors

fleuverouge avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

llenroc

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.