Taylor
包含许多类和辅助工具的 iOS 框架。
需求
- iOS 8.0+, tvOS 9.0+
- Xcode 9.4
- Swift 4(如果您需要 Swift < 2.3 支持,请使用
v1.1
标签)
安装
您可以使用 Carthage 将 Taylor
添加到您的 Cartfile
来安装。
github "mirego/taylor-ios"
CocoaPods
您可以使用 CocoaPods,通过将其添加到您的 Podfile
中来安装 Taylor
。
pod 'MRGTaylor'
手动
- 下载并将您需要的 Swift 文件拖放到您的项目中。
- 恭喜!
使用示例
import Taylor
let button = UIButton(type: .Custom)
button.setBorder(width: 2, color: .redColor())
安全区域填充
Taylor为UIView提供了一种向后兼容的safeAreaInsets
属性版本。原始API在iOS 11及更高版本中可用,并在旧操作系统中(包括iOS 7到10)填补了空白。这是一个可选功能,需要启用才能使用。
要启用此功能,请将以下代码放置在AppDelegate的application:didFinishLaunching:withOptions
方法中尽可能早的位置
UIViewController.enableCompatibilitySafeAreaInsets()
现在,您可以从任何UIView中访问compatibilitySafeAreaInsets
属性。在iOS 11及以上版本中,此属性返回safeAreaInsets
。要接收安全区域更新的回调,您的视图必须遵守CompatibilitySafeAreaInsetsUpdate
协议。
为了涵盖所有iOS版本,您的子视图可以如下所示
class BaseView: UIView, CompatibilitySafeAreaInsetsUpdate {
func compatibilitySafeAreaInsetsDidChange() {
commonSafeAreaInsetsDidChange()
}
@available(iOS 11.0, *)
override func safeAreaInsetsDidChange() {
super.safeAreaInsetsDidChange()
commonSafeAreaInsetsDidChange()
}
func commonSafeAreaInsetsDidChange() {
setNeedsLayout()
}
}
额外
- 存在一个(希望)与master保持更新的
no-bitcode
分支。
许可证
Taylor归© 2016 Mirego 所有,可自由分发,遵循新BSD许可。请参阅LICENSE.md
文件。
关于Mirego
Mirego 是一支充满热情的团队,我们相信工作是一个你可以创新和享受乐趣的地方。我们是一支 才华横溢的人 组成的团队,我们想象并构建美丽的网页和移动应用程序。我们聚在一起分享想法和 改变世界。
我们也热爱开源软件 ,并尽可能多地回馈社区。