TvOSTextViewer
tvOS 的轻量级可滚动视图控制器,用于显示文本块
描述
TvOSTextViewer 是一个视图控制器,用于以与 tvOS 本地应用相同的方式显示文本块。
可自定义属性
- text:要显示的文本块
- textEdgeInsets:文本的边距
- backgroundBlurEffectStyle:默认值为 .dark
- textAttributes:通过 NSAttributedText 进行自定义的字体/大小、文本颜色、对齐等...
要求
- tvOS 9.0+
- Xcode 11
安装
Cocoapods
CocoaPods 是一个 Cocoa 项目的依赖管理工具。您可以使用以下命令安装它:
$ gem install cocoapods
使用 Cocoapods 将 TvOSTextViewer 集成到您的 Xcode 项目中,请在其 Podfile 中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :tvos, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'TvOSTextViewer', '~> 1.3.0'
end
然后,运行以下命令
$ pod install
Carthage
Carthage 是一个去中心化的依赖管理器,用于构建您的依赖并提供二进制框架。
您可以使用 Homebrew 使用以下命令安装 Carthage:
$ brew update
$ brew install carthage
使用 Carthage 将 TvOSTextViewer 集成到您的 Xcode 项目中,请在其 Cartfile 中指定它
github "dcordero/TvOSTextViewer" ~> 1.2.0
运行 carthage update
命令构建框架,并将构建的 TvOSTextViewer.framework 拖放到您的 Xcode 项目中。
使用方法
您只需要创建一个 TvOSTextViewerViewController 实例并在屏幕上显示它。
let viewController = TvOSTextViewerViewController()
viewController.text = "Hello World"
present(viewController, animated: true, completion: nil)
如果您想显示此全屏视图,并从一个按钮中裁剪文本,您可以与 TvOSMoreButton 结合使用,由 cgoldsby 提供。