测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2017年6月 |
SwiftSwift 版本 | 3.1 |
SPM支持 SPM | ✗ |
由 Rehat Kathuria 维护。
一组用于UIView
的辅助方法和用于增强可读性的CGFloat
计算变量的集合。
通过CocoaPods提供。要安装,请将以下行添加到您的Podfile中
pod 'SetNeedsReadable'
使用居中辅助方法应限制在layoutSubviews:
、viewDidLayoutSubviews:
或适当的情况下的动画块中。在这些场景之外使用时,用户仍负责通过调用setNeedsLayout
将适当的视图标记为脏。要使用,只需在需要的地方导入SetNeedsReadable
模块。
foo.centerAlongHorizontalAxis(of: bar)
foo.centerAlongVerticalAxis(of: bar)
foo.centerHorizontally(between: bar, and: baz)
foo.center(inside: bar)
foo.centerVertically(between: bar, and: baz)
foo.alignInside(leftEdgeOf: bar)
foo.alignInside(rightEdgeOf: bar)
foo.alignInside(topEdgeOf: bar)
foo.alignInside(bottomEdgeOf: bar)
foo.alignOutside(leftEdgeOf: bar)
foo.alignOutside(rightEdgeOf: bar)
foo.alignOutside(topEdgeOf: bar)
foo.alignOutside(bottomEdgeOf: bar)
这些方法也可以在动画块内调用。
UIView.animate(withDuration: duration, delay: delay, options: [], animations: { [weak self] in
guard let weakSelf = self else { return }
weakSelf.foo.centerHorizontally(between: weakSelf.bar, and: weakSelf.baz)
weakSelf.foo.centerVertically(between: weakSelf.bar, and: weakSelf.baz)
})
存储库中有一个示例项目,演示了使用方法。
rehatkathuria
kthr.co/abt
SetNeedsReadable在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。