水滴 💧

一个 µFramework,用于显示类似于从剪贴板复制或连接 Apple 铅笔时使用的警报。

Demo


CI codecov

功能


用法

  1. 创建一个水滴
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"
)
  1. 显示它
Drops.show("Title")
Drops.show(drop)
SwiftUI
import SwiftUI
import Drops

struct ContentView: View {
    var body: some View {
        Button("Show Drop") {
            Drops.show(drop)
        }
    }
}
UIKit
import UIKit
import Drops

class ViewController: UIViewController {
    let drops = Drops(delayBetweenDrops: 1.0)

    func showDrop() {
        drops.show(drop)
    }
}

阅读 文档 以获取更多用法选项。


示例项目

Example


安装

Swift Package Manager

Swift Package Manager 是一个用于管理 Swift 代码分发的工具。

  1. 将以下内容添加到你的 Package.swift 文件中
dependencies: [
    .package(url: "https://github.com/omaralbeik/Drops.git", from: "1.7.0")
]
  1. 构建你的项目
$ swift build

CocoaPods

要使用 CocoaPods 将 Drops 集成到你的 Xcode 项目中,请在你的 Podfile 中指定它

pod 'Drops', :git => 'https://github.com/omaralbeik/Drops.git', :tag => '1.7.0'

Carthage

要使用 Carthage 将 Drops 集成到你的 Xcode 项目中,请在你的 Cartfile 中指定它

github "omaralbeik/Drops" ~> 1.7.0

手动

Sources 文件夹添加到你的 Xcode 项目中。


鸣谢

特别感谢 SwiftKickMobile 团队 创建了 SwiftMessages,这个项目深受他们的工作启发。


许可证

Drops 在 MIT 许可证下发布。有关更多信息,请参阅 LICENSE