override func prepare() {
var width: CGFloat!
let isIphone = UIDevice.current.isIphone()
let isLandscape = UIApplication.shared.statusBarOrientation.isLandscape
let bounds = UIScreen.main.bounds
let height = isIphone ? 72.0 : 92.0
let numberOfColumns = isIphone
? isLandscape ? CGFloat(2.0) : CGFloat(1.0)
: isLandscape ? CGFloat(3.0) : CGFloat(2.0)
let leftMargin = CGFloat(isIphone ? 8.0 : 16.0)
let rightMargin = CGFloat(isIphone ? 8.0: 16.0)
let topMargin = CGFloat(8.0)
minimumInteritemSpacing = 4.0
minimumLineSpacing = 16.0
width = ((bounds.width - leftMargin - rightMargin) / numberOfColumns ) - minimumInteritemSpacing * (numberOfColumns - 1)
sectionInset = UIEdgeInsets(top: topMargin, left: leftMargin, bottom: 0, right: rightMargin)
itemSize = CGSize(width: Double(width), height: height)
}
}
>количество колонок >float
Обсуждают сегодня