ASToast 1.1.2

ASToast 1.1.2

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最新发布2018年4月
SPM支持SPM

Abdullah Selek维护。



ASToast 1.1.2

  • Abdullah Selek

Build Status CocoaPods Compatible Carthage Compatible Coverage Status Platform License

ASToast

一个用于使用Android风格的Toast通知的Swift扩展。您可以直接从您的视图对象中调用ASToast方法。

截图

single_toast image_toast activity_toast

要求

ASToast 版本 最低iOS目标 Swift 版本
1.1.2 9.0 4.1
1.1.1 9.0 4.0
1.1.0 8.0 3.x
1.0.3 8.0 2.x

iOS 8.0+

CocoaPods

CocoaPods是Cocoa项目的依赖管理器。您可以使用以下命令安装它

$ gem install cocoapods

要使用CocoaPods将ASToast集成到您的Xcode项目中,在您的Podfile中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'ASToast', '~> 1.1.2'
end

然后,运行以下命令

$ pod install

Carthage

Carthage 是一个去中心化的依赖管理器,它帮你编译依赖并提供二进制框架。

您可以使用以下命令使用 Homebrew 安装 Carthage:

brew update
brew install carthage

要使用 Carthage 将 ASToast 集成到您的 Xcode 项目中,在您的 Cartfile 中指定它。

github "abdullahselek/ASToast" ~> 1.1.2

运行 carthage update 以构建框架,并将构建的 ASToast.framework 拖入您的 Xcode 项目。

用法示例

使用默认背景颜色和自定义消息颜色创建一个包含单一文本的 toast

self.view.makeToast(message: "Single text toast",
					backgroundColor: nil,
					messageColor: UIColor.cyan)

使用自定义背景颜色和白色消息颜色创建 toast

self.view.makeToast(message: "Single text toast",
					backgroundColor: UIColor.blue,
					messageColor: nil)

使用文本、标题、位置、持续时间和自定义颜色创建 toast

self.view.makeToast(message: "Toast with custom text, title and duration",
					duration: TimeInterval(3.0),
					position: .center,
					title: "Title",
					backgroundColor: UIColor.blue,
					titleColor: UIColor.yellow,
					messageColor: UIColor.yellow,
					font: UIFont.systemFont(ofSize: 16))

使用图像和自定义颜色创建 toast

self.view.makeToast(message: "Toast with an image",
					duration: TimeInterval(3.0),
					position: .top,
					image: UIImage(named: "apple_logo"),
					backgroundColor: UIColor.blue,
					titleColor: UIColor.yellow,
					messageColor: UIColor.yellow,
					font: UIFont.systemFont(ofSize: 16))

以 toast 的形式显示自定义视图

let customView: UIView! = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 300.0))
customView.autoresizingMask = [UIViewAutoresizing.flexibleLeftMargin,
							   UIViewAutoresizing.flexibleRightMargin,
							   UIViewAutoresizing.flexibleTopMargin,
							   UIViewAutoresizing.flexibleBottomMargin]
customView.backgroundColor = UIColor.green

self.view.showToast(toastView: customView,
					duration: TimeInterval(3.0),
					position: .bottom)

显示 imageView 作为 toast,位于 (110,110) 的中心点

let toastImageView: UIImageView! = UIImageView(image: UIImage(named: "apple_logo"))
self.view.showToast(toastView: toastImageView,
					duration: TimeInterval(3.0),
					point: CGPoint(x: 110, y: 110))

显示活动指示器

self.view.makeToastActivity()

隐藏活动指示器

self.view.hideToastActivity()

MIT 许可

Copyright (c) 2015 Abdullah Selek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

致谢

Inspired from Charles Scalesse (scalessec). Improved and all coded in new programming 
language Swift.