WWDC 2007 2008 2009 2010 2011 2012 2013 2014 2015
This file contains 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 BufferingStackView: UIStackView { | |
private var viewBuffer: ViewBuffer = ViewBuffer() | |
func prepare<T: UIView>(viewCount: Int, config: @escaping (_ index: Int, _ view: T) -> Void) { | |
let currentViewCount = self.arrangedSubviews.count | |
let neededViewCount = viewCount | |
let diff = neededViewCount - currentViewCount | |
let absDiff = abs(diff) | |
let shouldDelete = diff < 0 | |
if shouldDelete { | |
(0..<absDiff).forEach({ _ in |