UIKit组件

使用 UIKit 构建的可重用 UI 组件。

要求

组件

TextViewWithPlaceholder

带有占位符的 UITextView

let textView = TextViewWithPlaceholder()
textView.placeholder = "email@example.com"

// The appearance of the placeholder follows that of text view.
textView.font = .preferredFont(forTextStyle: .body)
textView.textAlignment = .center
textView.textContainerInset = .zero
textView.textContainer.lineFragmentPadding = 0
// etc...

在你的项目中使用 UIKitComponents

要在 SwiftPM 项目中使用 UIKitComponents 库,请将以下行添加到你的 Package.swift 文件中的依赖项:

.package(url: "https://github.com/jrsaruo/UIKitComponents", from: "1.0.4"),

并将 UIKitComponents 添加为你的目标的依赖项

.target(name: "<target>", dependencies: [
    .product(name: "UIKitComponents", package: "UIKitComponents"),
    // other dependencies
]),

最后,在你的源代码中添加 import UIKitComponents