托斯特iOS
为iOS提供全定制和轻量级的托斯特消息。此插件在swift代码中使用简单,只需一行代码即可触发托斯特消息。
新特性
- 解决了多托斯特消息和标题的bug
- 现在可以显示带有图片的托斯特消息
- 自定义托斯特消息图片的大小
截图
选项 | 仅标题 | 具有自定义样式的标题 |
---|---|---|
![]() |
![]() |
![]() |
标题和消息 | 具有自定义样式的标题和消息 | 自定义托斯特背景 |
---|---|---|
![]() |
![]() |
![]() |
顶部托斯特 | 中间托斯特 | 底部托斯特 |
---|---|---|
![]() |
![]() |
![]() |
显示带有图片的托斯特 | 带有自定义样式的图片托斯特 | - |
---|---|---|
![]() |
![]() |
- |
设置说明
Cocoapods
要将ToasteriOS集成到您的Xcode项目中使用CocoaPods,请在您的Podfile
中指定它。
pod 'ToasteriOS'
并在您的代码中添加import ToasteriOS
。
基本示例
如何使用ToasteriOS的基本示例
//Basic usage
self.showToaster(title: "Success", message: "Hello World!")
//With some aditional parameter to customize the toaster message possition
self.showToaster(title: "Success", message: "Hello World!", position: .middle)
更多自定义
如果您想更深入地自定义标题/消息/toaster背景视图的样式,请按照以下步骤操作。
//Custom style message
var titleStyle = ToasterMessageStyle()
titleStyle.font = UIFont.systemFont(ofSize: 18, weight: .bold) //Custom Font by default font is swift default font
titleStyle.textAlignment = .left //Alignment of the text possition by default the possition is left
titleStyle.textColor = .green //Custom colour for the text by default colour is green
var messageStyle = ToasterMessageStyle()
messageStyle.font = UIFont.systemFont(ofSize: 14, weight: .regular) //Custom Font by default font is swift default font
messageStyle.textAlignment = .left //Alignment of the text possition by default the possition is left
messageStyle.textColor = .white //Custom colour for the text by default colour is white
//Custom style for the toaster background
var backgroundStyle = ToasterBackgroundStyle()
backgroundStyle.backgroundColor = .black //Custom background color for the toaster by default the black color
backgroundStyle.cornerRadius = 5 //Set the corner radius value for the background by default value is 8
backgroundStyle.delay = 6
//Can show the toaster message with above custom style
self.showToaster(title: "success", message: "Hello World!", position: .top, titleStyle: titleStyle, messageStyle: messageStyle, toasterBacgroundStyle: backgroundStyle)
//Can show the toaster message with above custom style and with the image with style
self.showToaster(title: "success", message: "Hello World!", position: .top, titleStyle: titleStyle, messageStyle: messageStyle, toasterBacgroundStyle: backgroundStyle, isWithImage: true, toasterImage: #imageLiteral(resourceName: "success"), toasterSquareImageWidth: 80)
兼容性
- 版本5.x.x需要Swift 5和Xcode 10.2(或更高版本的Xcode)。
- 版本4.x.x需要Swift 4.2和Xcode 10。
MIT许可
Copyright (c) 2020 Achsuthan Mahendran.
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.