[英]Hello, I am using swift and I am trying to change a label of a collection view cell when the a collection view cell is selected
[英]Change design collection view cell when I redimensioned
我有一個問題,我有一個動態的集合視圖,啟動時我有3行,但是當更改滑塊,改變集合中的行數並調整了設計時,問題是設計錯誤,我可以嘗試使用self.myCarouselView.collectionViewLayout.invalidateLayout()
但不起作用,有什么幫助嗎? 在大小單元格中,我有以下代碼:
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: myCollection.bounds.size.width/CGFloat(numberOfYears), height: 120)
}
好奇是當我單擊圓圈時,設計更改為正確的格式...
Create one class from UICollectionViewFlowLayout, override the flow layout using this code
- (instancetype)init
{
self = [super init];
if (self)
{
self.minimumLineSpacing = 1.0;
self.minimumInteritemSpacing = 1.0;
self.scrollDirection = UICollectionViewScrollDirectionVertical;
}
return self;
}
- (CGSize)itemSize
{
NSInteger numberOfColumns = 3;
CGFloat itemWidth = (CGRectGetWidth(self.collectionView.frame) - (numberOfColumns - 1)) / numberOfColumns;
return CGSizeMake(itemWidth, itemWidth);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.