Latest 0.1.1
Homepage https://github.com/LINAICAI/Toast-Swift
License MIT
Platforms ios 8.0
Dependencies SnapKit
Frameworks UIKit, Foundation
Authors

Toast-Swift

CI Status
Version
License
Platform

Example

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

Before usage

import Toast

Basic usage

Toast("data submit success").show(self.view)
Toast("data submit success").show(self.view, Toast.Duration.short)
Toast("data submit success").show(self.view, Toast.Duration.long)
Toast("data submit success").show(self.view, Toast.Duration.custom(5.0))

More property

let toast = Toast("data submit success")
toast.gravity = .center
toast.cornerRadius = 10
toast.duration = .long
toast.offset = CGPoint.zero
toast.margin = 30
toast.padding = 20
toast.show(self.view)

Advanced usage

you can modify toast view by using(Add image to Toast):

let toast = Toast("Success")
let imageView = UIImageView(image: UIImage(named: "success")?.withRenderingMode(UIImageRenderingMode.alwaysTemplate))
imageView.tintColor = UIColor.white
let view = toast.view;
let label = view.subviews.last as! UILabel
view.addSubview(imageView)
imageView.snp.makeConstraints { (make) in
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(toast.padding)
make.bottom.equalTo(label.snp.top).offset(-toast.padding)
make.size.equalTo(CGSize(width: 35, height: 35))
}
label.snp.remakeConstraints { (make) in
make.left.equalToSuperview().offset(toast.padding)
make.right.equalToSuperview().offset(-toast.padding)
make.bottom.equalToSuperview().offset(-toast.padding)
}
toast.show(self.view)

Customize usage

you can customize toast view by using(use your view add to Toast):

let toast = Toast()
let custom:UIView = UIView()
let label = UILabel()
label.text = "Custom Toast"
label.textColor = UIColor.white
custom.addSubview(label)
label.snp.makeConstraints { (make) in
make.edges.equalTo(UIEdgeInsetsMake(toast.padding, toast.padding, toast.padding, toast.padding))
}
custom.backgroundColor = UIColor.black
toast.view = custom
toast.gravity = Toast.Gravity.center
toast.show(view, Toast.Duration.short)

Requirements

iOS8+
Swift 4
Xcode9+

Installation

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

pod 'Toast-Swift-Android-Like'

Author

Nice, [email protected]

License

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

Latest podspec

{
    "name": "Toast-Swift-Android-Like",
    "version": "0.1.1",
    "summary": "u4effu7167u5b89u5353u7cfbu7edfToastu7684u5199u6cd5u5b8cu6210u7684u4e00u4e2au5c5eu4e8eiOSu7cfbu7edfu5e76u4e14u6bd4u8f83u597du6269u5c55u7684u901au7528Toastu7ec4u4ef6.",
    "description": "u8bf7u6ce8u610fuff0cu672cu7ec4u4ef6u7f16u5199u7684u521du8877u662fu4f5cu8005u6bd4u8f83u6b23u8d4fu5b89u5353Toastu7684u8bbeu8ba1u601du8defuff0cu5e76u4e0du4ee3u8868u5728iOSu5e73u53f0u4e0au5c31u7eddu5bf9u9002u5408uff0cu7f16u5199u8fc7u7a0bu4e2du4e5fu7531u4e8ejavau3001OCu548cSwiftu7684u8bedu8a00u4e60u60efu4e0du540cu800cu53d6u5176u7cbeu534eu53bbu5176u7cdfu7c95u5b8cu6210uff0cu53e6u5916u4f5cu8005u5f3au70c8u5efau8baeu4f7fu7528u65f6u518du6b21u5c01u88c5u6210u66f4u65b9u4fbfu4f7fu7528u7684u5b9au5236u7ec4u4ef6(u5982u94feu5f0fu8c03u7528u6216u8005u7c7bu65b9u6cd5u8c03u7528u3001u5206u7c7bu8c03u7528)uff0cu6b22u8fceu559cu6b22OOPu7684u540cu5b66u6307u51fau4ee3u7801u4e2du4e0du5408u7406u7684u5730u65b9u3002",
    "homepage": "https://github.com/LINAICAI/Toast-Swift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Nice": "[email protected]"
    },
    "source": {
        "git": "https://github.com/LINAICAI/Toast-Swift.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Toast/Classes/**/*",
    "frameworks": [
        "UIKit",
        "Foundation"
    ],
    "dependencies": {
        "SnapKit": [
            "~> 4.0.0"
        ]
    },
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This