Stackable 1.0.0

Stackable 1.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2020年1月
SPM支持SPM

Maintained by Shaun Ervine, Ronny Chan, Juan Reyes, Megan Efron.



Stackable 1.0.0

  • SEEK

seek-stackable

是一款为iOS `UITableViewCell`实现垂直和水平嵌套视图布局的框架。

历史

我们希望能够在不牺牲滚动平滑性的情况下,不必维护frame布局代码来对高度可变的UITableViewCell进行布局。

为什么使用Stackable?

  • 它仅仅是框架
  • 获得frame布局的性能,而不需要大量代码
  • 声明式视图表达式使代码集成变得容易
  • 框架可以被缓存
  • 框架是不可变的
  • 可以通过协议扩展扩展以支持各种控件
  • 与标准UIKit控件接口对接
  • 目前由SEEK iOS App用于搜索结果

它不是什么

  • stackable 并不是 UIStackView 的替代品
    • stackable 不像 UIStackView 那样是动态的,而是依赖于不可变的框架
    • 目前,stackable 没有提供 UIStackView 中的一些功能,如对齐选项,但这种情况将随着时间的推移而改变
  • stackable 不是基于 AutoLayout 的
    • AutoLayout 很强大,但调整其性能比较困难

当前限制

  • 仅与 UILabel 和 UIImageView 集成已过验证
  • 没有对齐选项
  • 没有分布选项

示例

let descriptionLabel = UILabel()
let attribute1 = UILabel()
let attribute2 = UILabel()
let attribute3 = UILabel()
let logoImageView = UIImageView()

let stack = VStack(spacing: 2) {[
  HStack(spacing: 10) {[
    VStack(spacing: 1) {[
      attribute1,
      attribute2,
      attribute3
    ]},
    logoImageView.stackSize(100, 100)
  ]},
  descriptionLabel
]}

let width = self.frame.size.width

// give me the frames
let stackedFrames = stack.framesForLayout(width)

// how tall is the stack?
let height = stack.heightForFrames(stackedFrames)

// lay the frames out
stack.layoutWithFrames(stackedFrames)