Skip to content

Instantly share code, notes, and snippets.

@TheFinestArtist
Created July 25, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFinestArtist/cbdbcd49eaedfb60cca4 to your computer and use it in GitHub Desktop.
Save TheFinestArtist/cbdbcd49eaedfb60cca4 to your computer and use it in GitHub Desktop.
CRToast+Custom
//
// CRToast+Custom.h
// Custom
//
// Created by The Finest Artist
//
//
#import <CRToast/CRToast.h>
@interface CRToastManager (Custom)
+ (void)showWithMessage:(NSString *)message;
+ (void)errorWithMessage:(NSString *)message;
@end
//
// CRToast+Custom.m
// Custom
//
// Created by The Finest Artist
//
//
#import "CRToastManager+Custom.h"
@implementation CRToastManager (Custom)
+ (void)showWithMessage:(NSString *)message {
CRToastInteractionResponder *responder = [CRToastInteractionResponder interactionResponderWithInteractionType:CRToastInteractionTypeAll
automaticallyDismiss:YES
block:^(CRToastInteractionType interactionType) {}];
NSDictionary *options = @{
kCRToastNotificationTypeKey : @(CRToastTypeNavigationBar),
kCRToastNotificationPresentationTypeKey : @(CRToastPresentationTypeCover),
kCRToastUnderStatusBarKey : @(NO),
kCRToastImageKey : [UIImage imageNamed:@"alert_icon.png"],
kCRToastTextKey : message,
kCRToastFontKey : [UIFont systemFontOfSize:16.f],
kCRToastTextAlignmentKey : @(NSTextAlignmentLeft),
kCRToastBackgroundColorKey : UIColorFromRGB(kColorGray),
kCRToastTextAlignmentKey : @(NSTextAlignmentCenter),
kCRToastTextMaxNumberOfLinesKey : @(2),
kCRToastTimeIntervalKey : @(1.5f),
kCRToastAnimationInTypeKey : @(CRToastAnimationTypeGravity),
kCRToastAnimationOutTypeKey : @(CRToastAnimationTypeLinear),
kCRToastAnimationInDirectionKey : @(CRToastAnimationDirectionTop),
kCRToastAnimationOutDirectionKey : @(CRToastAnimationDirectionTop),
kCRToastInteractionRespondersKey : [NSArray arrayWithObject:responder]
};
[CRToastManager showNotificationWithOptions:options completionBlock:nil];
}
+ (void)errorWithMessage:(NSString *)message {
CRToastInteractionResponder *responder = [CRToastInteractionResponder interactionResponderWithInteractionType:CRToastInteractionTypeAll
automaticallyDismiss:YES
block:^(CRToastInteractionType interactionType) {}];
NSDictionary *options = @{
kCRToastNotificationTypeKey : @(CRToastTypeNavigationBar),
kCRToastNotificationPresentationTypeKey : @(CRToastPresentationTypeCover),
kCRToastUnderStatusBarKey : @(NO),
kCRToastImageKey : [UIImage imageNamed:@"alert_icon.png"],
kCRToastTextKey : message,
kCRToastFontKey : [UIFont systemFontOfSize:16.f],
kCRToastTextAlignmentKey : @(NSTextAlignmentLeft),
kCRToastBackgroundColorKey : UIColorFromRGB(kColorRed),
kCRToastTextAlignmentKey : @(NSTextAlignmentCenter),
kCRToastTextMaxNumberOfLinesKey : @(2),
kCRToastTimeIntervalKey : @(1.5f),
kCRToastAnimationInTypeKey : @(CRToastAnimationTypeGravity),
kCRToastAnimationOutTypeKey : @(CRToastAnimationTypeLinear),
kCRToastAnimationInDirectionKey : @(CRToastAnimationDirectionTop),
kCRToastAnimationOutDirectionKey : @(CRToastAnimationDirectionTop),
kCRToastInteractionRespondersKey : [NSArray arrayWithObject:responder]
};
[CRToastManager showNotificationWithOptions:options completionBlock:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment