Giter Site home page Giter Site logo

liangxiuchen / clxtoast Goto Github PK

View Code? Open in Web Editor NEW
24.0 3.0 2.0 5.32 MB

a powerful Toast by swift and Objectivie-C, which has hud and waiting Style . it also has Appearance,Cancel, Custom toast content and avoid overlap.

License: MIT License

Ruby 1.90% Swift 43.88% Objective-C 54.22%
toast swift hud ios objective-c

clxtoast's Introduction

CLXToast

CI Status Version License Platform

Overview

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CLXToast is available through CocoaPods. To install it, simply add the following line to your Podfile:

Swift

pod 'CLXToast'

Objective-C

pod 'CLXToast/Objc-Toast'

Usage After 0.2.0

//----------------------------------HUD Style--------------------------------------------
Toast.hudBuilder.title("it is a title").show()
Toast.hudBuilder.subtitle("it is a subtitle").show()
Toast.hudBuilder.icon(UIImage(named: "toast")).show()
Toast.hudBuilder.title("it is a title").subtitle("it is a subtitle").show()
Toast.hudBuilder.title("it is a long long long long long long long title").subtitle("it is a long long long long long long long long long long long longsubtitle").icon(#imageLiteral(resourceName: "toast")).show()

 //adjust titles space demo
Toast.hudBuilder.title("adjust space").subtitle("adjust space between title and subtitle").interTitlesSpacing(10).show()
Toast.hudBuilder.title("adjust space").subtitle("adjust space between titles and icon").icon(#imageLiteral(resourceName: "toast")).interTitlesIconSpacing(10).show()

//custom subtitle Lable same as title and icon demo
let subtitle = UILabel()
subtitle.text = "adjust space between titles and icon"
subtitle.preferredMaxLayoutWidth = 40
subtitle.numberOfLines = 0
let title = UILabel()
title.text = "it is a title"
title.preferredMaxLayoutWidth = 100
title.numberOfLines = 0
title.font = UIFont.systemFont(ofSize: 16)
title.textColor = UIColor.green
Toast.hudBuilder.titleLabel(title).subtitleLabel(subtitle).icon(#imageLiteral(resourceName: "toast")).show()

//completion callback demo
Toast.hudBuilder.title("it is a completion callback test").show(animated: true) {
      print("--------------------hud is finished--------------------")
}

//config toast instance        
let tst = Toast()        
tst.isConcurrent = true        
tst.contentView.backgroundColor = UIColor.green        
tst.aHud.title("it is a concurrent toast").show()

// full custom hud Demo        
let customHud = CustomHudContent()        
let toast = Toast()
toast.custom(content: customHud).show()

//cancel demo
Toast.hudBuilder.title("i will cancel all.").show(animated: true) {
  Toast.hudBuilder.title("i will never appear").show()
  Toast.cancelAll()
}

//----------------------------------Waiting Style--------------------------------------------

let allItemWaiting = Toast.waiting.prompt("同步中...").show()
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
    allItemWaiting.dismiss()
}

DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(4)) {
    let waitingWithCallBack = Toast.waiting.prompt("等待完成回调...").show(animated: true) {
        Toast.hudBuilder.title("waiting completion").show()
        }
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
            waitingWithCallBack.dismiss()
        }
}
        

Usage Before 0.2.0

//HUD Style
Toast().title("nihao").subtitle("subtitle").show()
Toast(style: .hud).title("nihao").subtitle("subtitle").show(animated: true)
Toast(style: .hud).title("nihao").subtitle("subtitle").show(animated: true) {
      DispatchQueue.main.async {
          Toast.cancelAll()
          }
      }
// waiting Style
let toast = Toast(style: .waiting).prompt("hello waiting").show(animated: false) {
    print("default waiting")
    }
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) {
    toast.dismiss()
    }
   

Author

liangxiuchen

License

CLXToast is available under the MIT license. See the LICENSE file for more info.

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.