Code Monkey home page Code Monkey logo

gkrtoast's Introduction

GKRToast

iOS replay for Android Toast messages made with easy customization in mind.

How to use

For default style toast just write:

[GKRToast show:@"Your text"];

For other style use one of two classes AIMToast or AIMFancyToast or create custom subclass

Check video on Youtube or try it by yourself

Check the full video

or try it by yourself

Available classes and styles

GKRToast - base class with Android look'n'feel

AIMToast - class that we are using at All in Mobile, background and text color can be easly customized

AIMFancyToast - example how to create more complicated animations

Custom subclass

If you want make a toast with custom layout and animation, you should create a subclass of GKRToast, override + (GKRToastConfigure *)configure method and return new configuration for toast. For example if you want to create a toast, that shows from left-hand side, you should write something like that:

+ (GKRToastConfigure *)configure {
    GKRToastConfigure *configure = [GKRToastConfigure new];
    
    CGFloat offset = CGRectGetWidth([UIScreen mainScreen].bounds) * 0.5f + 100;
    
    configure.animateShowLabel = ^(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) {
        centerX.offset = -offset;
        [textContainer layoutIfNeeded];
        centerX.offset = 0;
        [UIView animateWithDuration:1.0f animations:^{
            [textContainer layoutIfNeeded];
        }];
    };
    return configure;
};

GKRToastConfigure properties

The GKRToastConfigure object has the following properties:

Property Type Description Default value
backgroundView UIView * background displayed full screen back color with 30% alpha
textContainer UIView * container for text message back color with 80% alpha
textLabel UILabel * label that display message text whte text color, number of line set to 0
textEdgeInsets UIEdgeInsets margin for textLabel left, right, top and bottom set to 10 pt
hideTimeOut NSTimeInterval displaying time (in secounds); if set to 0, never hides autmaticly 5s
animateShowLabel void(^)(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) block call after textContainer is add to current window; centerX and centerY are constrains that center toast on screen alpha transition from 0 to 1 in 0.5 s
animateShowBackground void(^)(UIView *backgroundView) block call after backgroundView is add to current window alpha transition from 0 to 1 in 0.5 s
animateHideLabel void(^)(UIView *textContainer, UILabel *textLabel, MASConstraint *centerX, MASConstraint *centerY) block call when textContainer should be remove from current window; remember to call [textLabel removeFromSuperview] and [textContainer removeFromSuperview] after animation is ended alpha transition from 1 to 0 in 0.5 s
animateHideBackground void(^)(UIView *backgroundView) block call when backgroundView should be remove from current window; remember to call [backgroundView removeFromSuperview] after animation is ended alpha transition from 1 to 0 in 0.5 s

gkrtoast's People

Contributors

maciejgad avatar lukkonior avatar

Stargazers

Ethan Kwong avatar Hardik Amal avatar Pranav Lathigara avatar Michal Tomaszewski avatar  avatar k.rzeznicki avatar SzymonJarosz avatar  avatar

Watchers

 avatar James Cloos avatar  avatar Krzysztof Rodak avatar Marek Kotewicz avatar k.rzeznicki avatar Wojciech Stasiński avatar Michał Mynarski avatar  avatar  avatar

gkrtoast's Issues

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.