I have a horizontal collection view in my project which has 2 elements - a button and a label. Button and label are stuck to each other and then I want to show other button and label within the cell with space between 2 elements ie Button 1 and label 1, then some space and then display button 2 and label 2. Want to have some space between label 1 and button 2.
I came across some 'UICollectionViewFlowLayout' related methods and did try adding the code for it to test, but the functions are not getting called. Below are the functions:
extension MyController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 50
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 100
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 100, bottom: 100, right: 100)
}
}
However adding 'UICollectionViewFlowLayout' is giving me "Inheritance from non-protocol type 'UICollectionViewFlowLayout'"
error.
How can I get 'minimumLineSpacingForSectionAt' and other methods executed? Or how can I add space between label 1 and button 2, and then space between label 2 and button 3?
It is UICollectionViewDelegateFlowLayout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.