我試圖調整UICollectionView的高度,將視圖控制器加載時設置爲0,然後在按下按鈕時使用動畫增加其大小。我嘗試了一些不同的東西,但它的大小根本不變。這裏的所有不同的東西,我試圖把它的高度更改爲0:調整大小UICollectionView高度
CGRect bounds = [self.collectionView bounds];
[self.collectionView setBounds:CGRectMake(bounds.origin.x,
bounds.origin.y,
bounds.size.width,
bounds.size.height - 100)];
....
CGRect frame = [self.collectionView frame];
[self.collectionView setFrame:CGRectMake(frame.origin.x,
frame.origin.y,
frame.size.width,
frame.size.height - 100)];
....
CGRect frame = self.collectionView.frame;
frame.size.height -= 100;
self.collectionView.frame = frame;
....
self.collectionView.clipsToBounds = YES;
self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
是'self.collectionView'實際設置的東西?你在使用AutoLayout嗎? – mattjgalloway
我將集合視圖設置爲出口。是AutoLayout已打開。 –
如果你使用AutoLayout,那麼你將不得不改變約束而不是直接改變框架。您需要在集合視圖上設置高度限制。 – mattjgalloway