
Но у меня есть такой результат:
[img]https://i.stack.imgur.com /gyAL0.jpg[/img]
код:
func carouselSection(using section: Section) -> NSCollectionLayoutSection {
///` "Item":
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalHeight(1.0), heightDimension: .fractionalHeight(1.0))
let layoutItem = NSCollectionLayoutItem(layoutSize: itemSize)
layoutItem.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
///` "Group":
let layoutGroupSize = NSCollectionLayoutSize(widthDimension: .fractionalHeight(1.0), heightDimension: .fractionalHeight(1.0))
let layoutGroup = NSCollectionLayoutGroup.horizontal(layoutSize: layoutGroupSize, subitems: [layoutItem])
///` "Section":
let layoutSection = NSCollectionLayoutSection(group: layoutGroup)
layoutSection.orthogonalScrollingBehavior = .groupPagingCentered
layoutSection.visibleItemsInvalidationHandler = { (items, offset, environment) in
items.forEach { item in
let frame = item.frame
let rect = CGRect(x: offset.x, y: offset.y, width: environment.container.contentSize.width, height: frame.height)
let inter = rect.intersection(frame)
let percent: CGFloat = inter.width / frame.width
let scale = 0.8 + (0.2 * percent)
item.transform = CGAffineTransform(scaleX: 0.98, y: scale)
}
}
return layoutSection
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... onallayout