CRToast icon indicating copy to clipboard operation
CRToast copied to clipboard

not an issue, but a swift example

Open AndreiD opened this issue 9 years ago • 3 comments

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!")
        })

AndreiD avatar Aug 08 '16 11:08 AndreiD

thanks but its giving errors in swift 3

nadimalam avatar Jul 27 '17 14:07 nadimalam

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.

ryanjunp avatar Sep 07 '17 03:09 ryanjunp

good

CocoaDebug avatar Feb 01 '18 07:02 CocoaDebug