可展开的

概述

此包提供了一个可定制的、跨平台的 SwiftUI 视图,它模仿了 App Store 中可展开的应用程序描述 UI。

特性

安装

使用 Swift Package Manager 将此包添加到您的项目中

  1. 在 Xcode 中,前往 File > Add Packages...
  2. 输入此包的存储库 URL 或路径。
  3. 将包添加到您的项目。

或者,将以下内容添加到您的 Package.swift 依赖项中

dependencies: [
    .package(url: "https://github.com/ryanashcraft/Expandable.git", from: "1.0.0")
]

屏幕截图

iOS

iOS

macOS

macOS

watchOS

watchOS

用法

以下是如何在 SwiftUI 中使用 Expandable 视图的示例。

import Expandable
import SwiftUI

struct ContentView: View {
    var body: some View {
        ScrollView {
            Expandable {
                Text("Here’s to the crazy ones. The misfits. The rebels. The troublemakers. The round pegs in the square holes. The ones who see things differently. They’re not fond of rules. And they have no respect for the status quo. You can quote them, disagree with them, glorify or vilify them. About the only thing you can’t do is ignore them. Because they change things. They push the human race forward. And while some may see them as the crazy ones, we see genius. Because the people who are crazy enough to think they can change the world, are the ones who do.")
            } buttonLabel: {
                Text("more")
            }
            .lineLimit(3)
        }
    }
}

许可证

此软件包在 MIT 许可证下发布。 有关详细信息,请参见 LICENSE