Skip to content

Instantly share code, notes, and snippets.

@santoshrajan
Created November 9, 2014 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santoshrajan/09dd69257a53b183a1a2 to your computer and use it in GitHub Desktop.
Save santoshrajan/09dd69257a53b183a1a2 to your computer and use it in GitHub Desktop.
class VerticalFitLayout: VerticalLayout {
override init(width: CGFloat) {
super.init(width: width)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
var height: CGFloat = 0
var zeroHeightView: UIView?
for i in 0..<subviews.count {
var view = subviews[i] as UIView
height += yOffsets[i]
if view.frame.height == 0 {
zeroHeightView = view
} else {
height += view.frame.height
}
}
if height < superview!.frame.height && zeroHeightView != nil {
zeroHeightView!.frame.size.height = superview!.frame.height - height
}
super.layoutSubviews()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment