如果我使用集合视图使用显示图像,则无法正确显示(设计)图像。但我想按照方法显示图像。
如果我正在使用UICollectionView图像,则首先使用水平滚动视图(方向)正确显示9个图像。但是下一个图像(10)继续空间图像。
如何使用页面控制显示图像。如果使用UICollectionView页面控件问题就会出现。如何使用页面控制功能(如给定图像)显示图像
答案 0 :(得分:0)
您可以使用 UICollectionViewDelegateFlowLayout 来管理您设计的图片......
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize.init(width: ScreenWidth/2-10 , height: 160)//you can return a/c to your design
}
并使用滚动视图委托方法处理页面控制...只需做一件事情启用集合视图分页属性
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let currentValue = Int(collectionView.contentOffset.x/ScreeWidth)//here u will get value for page control to set current page ...
}