Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not an issue, but a swift example #205

Open
AndreiD opened this issue Aug 8, 2016 · 3 comments
Open

not an issue, but a swift example #205

AndreiD opened this issue Aug 8, 2016 · 3 comments

Comments

@AndreiD
Copy link

AndreiD commented Aug 8, 2016

Here's an example using swift. Maybe add it in the readme somewhere, because digging though stackoverflow is not nice.

import CRToast

//somewhere....
        var options:[NSObject:AnyObject]  = [
                kCRToastTextKey : "Hello World! This is a sample message up after loading the view",
                kCRToastBackgroundColorKey : UIColor.blackColor(),
                kCRToastTextColorKey: UIColor.yellowColor(),
                kCRToastTextMaxNumberOfLinesKey: 2,
                kCRToastTimeIntervalKey: 3,
                kCRToastUnderStatusBarKey : NSNumber(bool: false),
                kCRToastTextAlignmentKey : NSTextAlignment.Left.rawValue,
                //options[kCRToastImageKey] = UIImage(named: "ic_whatever") as AnyObject?
                kCRToastNotificationTypeKey : CRToastType.NavigationBar.rawValue,
                kCRToastAnimationInTypeKey : CRToastAnimationType.Gravity.rawValue,
                kCRToastAnimationOutTypeKey : CRToastAnimationType.Gravity.rawValue,
                kCRToastAnimationInDirectionKey : CRToastAnimationDirection.Top.rawValue,
                kCRToastAnimationOutDirectionKey : CRToastAnimationDirection.Top.rawValue
        ]

        CRToastManager.showNotificationWithOptions(options, completionBlock: { () -> Void in
            print("done!")
        })

@nadimalam
Copy link

thanks but its giving errors in swift 3

@ryanjunp
Copy link

ryanjunp commented Sep 7, 2017

let options: [String: Any] = [kCRToastTextKey: "Member joined: (member.identity)",
kCRToastTextAlignmentKey: NSTextAlignment.center,
kCRToastBackgroundColorKey: UIColor.red,
kCRToastAnimationInTypeKey: CRToastAnimationType.gravity,
kCRToastAnimationOutTypeKey: CRToastAnimationType.gravity,
kCRToastAnimationInDirectionKey: CRToastAnimationDirection.left,
kCRToastAnimationOutDirectionKey: CRToastAnimationDirection.right]

    CRToastManager.showNotification(options: options) {
        print("completed")
    }

This one is working example.

@CocoaDebug
Copy link

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants