CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

TTToast 0.0.3

TTToast 0.0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2015
SPMSupports SPM

Maintained by Tatsuya Tanaka.



TTToast 0.0.3

  • By
  • Tatsuya Tanaka

A simple toast library written by Swift

TTToast

Installation

Manually

Add manually:

  1. Add TTToast.swift to your project.
  2. Link QuartzCore.

Examples

// simple
Toast.show("Hello world\nToast test")

// customization
Toast.show("Hello world\nToast test", view:self.view) {(config) in
    // appearance
    config.maxWidth = CGFloat(0.8)
    config.paddingHorizontal = CGFloat(10.0)
    config.paddingVertical = CGFloat(10.0)
    config.cornerRadius = CGFloat(8)
    config.alpha = CGFloat(0.5)
    config.font = UIFont(name: "SnellRoundhand", size: 25.0)
    config.textColor = UIColor(red: 0.192, green: 0.216, blue: 0.082, alpha: 1.0)
    config.backgroundColor = UIColor(red: 0.886, green: 0.976, blue: 0.72, alpha: 1.0)
    // shadow
    config.shadow = true
    config.shadowOpacity = Float(0.5)
    config.shadowRadius = CGFloat(10.0)
    config.shadowOffset = CGSizeMake(4.0, 4.0)
    config.shadowColor = UIColor(red: 0.576, green: 0.624, blue: 0.36, alpha: 1.0).CGColor
    // duration
    config.durationBefore = 1.0
    config.duration = 2.0
    config.durationAfter = 0.5
    // position
    config.position = Toast.Position.Bottom.rawValue | Toast.Position.Right.rawValue
}

// global settings
Toast.config.backgroundColor = UIColor.blackColor()
Toast.config.textColor = UIColor.whiteColor()

Objective-C

If you use this library in Objective-C, you need to import the following:

#import <TTToast/TTToast.h>
#import <TTToast/TTToast-Swift.h> // auto-generated header file

and set [Build Settings]-[Build Options]-[Embeedded Content Contains Swift Code] to Yes.

Examples for Objective-C

[TTToast show:@"Hello world"];

[TTToast show:message:@"Hello world" view:self.view config:^(TTToastConfig* config) {
    config.backgroundColor = [UIColor blackColor];
    config.position = TTToastPositionTop | TTToastPositionLeft
}];

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

TTToast is released under the MIT license. See LICENSE for details.