测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可 | MIT |
Released上次发布 | 2017年5月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由Taiki Suzuki维护。
SAInboxViewController 实现了类似收件箱的视图转换。
您可以从这里在网页浏览器中启动示例项目。
将 SAInboxViewController 目录添加到您的项目中。
如果您通过 CocoaPods 安装,则需要写入 import SAInboxViewController
。
首先,请使用 SAInboxViewController
与 UINavigationController
。
有四个 ViewController 用于实现收件箱转换,请扩展这些 ViewController。
SAInboxViewController
... 作为根 ViewController 使用SAInboxDetailViewController
... 作为第二个 ViewController 使用这些 ViewController 有 UITableView
,因此请使用该 tableView 实现普通 UITableView
行为。
如果您在扩展 SAInboxDetailViewController
的 ViewController 中使用 UITableViewDelegate
,请调用以下两个方法中的超类方法。
override func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
super.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)
}
override func scrollViewDidScroll(scrollView: UIScrollView) {
super.scrollViewDidScroll(scrollView)
}
如果您要从根 ViewController 显示 ViewController,则实现 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
,如下所示。
@objc(tableView:didSelectRowAtIndexPath:)
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let viewController = SAInboxDetailViewController()
if let cell = tableView.cellForRow(at: indexPath), let image = headerView.screenshotImage() {
SAInboxAnimatedTransitioningController.sharedInstance.configureCotainerView(self, cell: cell, cells: tableView.visibleCells, headerImage: image)
}
navigationController?.pushViewController(viewController, animated: true)
}
实现 UINavigationControllerDelegate
方法,如下所示。
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return SAInboxAnimatedTransitioningController.sharedInstance.setOperation(operation)
}
您可以更改 HeaderView 的 barTintColor
、tintColor
和 titleTextAttributes
。
更改 HeaderView 外观有两种方式。
SAInboxViewController 类具有 Appearance 属性
SAInboxViewController.appearance.barTintColor = .black
SAInboxViewController.appearance.tintColor = .white
SAInboxViewController.appearance.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]
SAInboxViewController实例具有外观属性。
override func viewDidLoad() {
super.viewDidLoad()
appearance.barTintColor = .white
appearance.tintColor = .black
appearance.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.black]
//Do not forget to set true
enabledViewControllerBasedAppearance = true
}
铃木太希,[email protected]
SAInboxViewController遵守MIT许可证。有关更多信息,请参阅LICENSE文件。