“targetContentOffset” UICollectionViewFlowLayout not working properly
问题 I have a requirement to keep UICollectionViewCell center aligned in portrait mode. Final result should be like : animation I'm using this code to do this: override public func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { var layoutAttributes: Array = layoutAttributesForElements(in: collectionView!.bounds)! if layoutAttributes.count == 0 { return proposedContentOffset } var firstAttribute: