Giter Site home page Giter Site logo

hwtoast's Introduction

HWToast

What

HWToast can display a toast with custom views in a flexible way.

How

HWToastMaker

You can make a toast easily with a maker:

[HWToast showToastWithMaker:^(HWToastMaker *maker) {
    // Superview of the toast. If the baseView is nil, the toast will be added to a new window over the screen.
    maker.baseView = nil;

    // The toast view. It could be a text toast(HWTextToastView) 、 a loading toast(HWLoadingToastView) or other HWToastView.
    maker.contentView = [[HWTextToastView alloc] initWithText:text];

    // The toast will disappear after duration. Default value is 0 and it will be on the screen permanently.
    maker.duration = 0.2f;

    // Should it be dismissed on taped. Default is NO.
    maker.shouldDismissOnTaped = YES;

    // Whether the dismiss will be animated.
    maker.dismissAnimated = YES;

    // The callback will be called after the toast been taped.
    maker.tapCallback = ^(UIView *view){
        NSLog(@"You touched me!");
    };

    // The toast's position according to baseView
    maker.position = HWToastPositionBottom;

    // The offset relative to the position.
    maker.offsset = UIOffsetMake(0, -100);
}];

You can also abstract the maker block into class methods:

@implementation HWToastTool

+(void)showToastWithText:(NSString*)text {
    [HWToast showToastWithMaker:^(HWToastMaker *maker) {
        maker.contentView = [[HWTextToastView alloc] initWithText:text];
        maker.duration = 2.0f;
    }];
}

@end

And call like this:

[HWToastTool showToastWithText:@"Hi, I'm a toast from HWToastTool!"];

HWToastView

You can make your custom toast view inheriting from HWToastView.

Just like HWTextToastViewHWLoadingToastView and HWPieChartToastView.

hwtoast's People

Contributors

callmewhy avatar

Watchers

ruanjh 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.