一个 µFramework,用于显示类似于从剪贴板复制或连接 Apple 铅笔时使用的警报。
let drop: Drop = "Title Only"
let drop = Drop(title: "Title Only")
let drop = Drop(title: "Title", subtitle: "Subtitle")
let drop = Drop(title: "Title", subtitle: "Subtitle", duration: 5.0)
let drop = Drop(
title: "Title",
subtitle: "Subtitle",
icon: UIImage(systemName: "star.fill"),
action: .init {
print("Drop tapped")
Drops.hideCurrent()
},
position: .bottom,
duration: 5.0,
accessibility: "Alert: Title, Subtitle"
)
Drops.show("Title")
Drops.show(drop)
import SwiftUI
import Drops
struct ContentView: View {
var body: some View {
Button("Show Drop") {
Drops.show(drop)
}
}
}
import UIKit
import Drops
class ViewController: UIViewController {
let drops = Drops(delayBetweenDrops: 1.0)
func showDrop() {
drops.show(drop)
}
}
阅读 文档 以获取更多用法选项。
SwiftUIExample
目标以查看 Drops 在 SwiftUI 应用程序中的工作方式。UIKitExample
目标以查看 Drops 在 UIKit 应用程序中的工作方式。Swift Package Manager 是一个用于管理 Swift 代码分发的工具。
Package.swift
文件中dependencies: [
.package(url: "https://github.com/omaralbeik/Drops.git", from: "1.7.0")
]
$ swift build
要使用 CocoaPods 将 Drops 集成到你的 Xcode 项目中,请在你的 Podfile 中指定它
pod 'Drops', :git => 'https://github.com/omaralbeik/Drops.git', :tag => '1.7.0'
要使用 Carthage 将 Drops 集成到你的 Xcode 项目中,请在你的 Cartfile 中指定它
github "omaralbeik/Drops" ~> 1.7.0
将 Sources 文件夹添加到你的 Xcode 项目中。
特别感谢 SwiftKickMobile 团队 创建了 SwiftMessages,这个项目深受他们的工作启发。
Drops 在 MIT 许可证下发布。有关更多信息,请参阅 LICENSE。