Created
November 9, 2014 05:46
-
-
Save santoshrajan/09dd69257a53b183a1a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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