gpt4 book ai didi

xcode - 调整 UICollectionView 高度

转载 作者:行者123 更新时间:2023-12-04 08:12:06 25 4
gpt4 key购买 nike

我试图通过在加载 View Controller 时将其设置为 0 来调整 UICollectionView 高度的大小,然后在按下按钮时通过动画增加其大小。我尝试了一些不同的东西,但它的大小根本没有改变。这是我尝试将其高度更改为 0 的所有不同内容:

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;

最佳答案

如果您使用 Interface Builder 进行 UICollectionView 初始化,请从创建 CollectionView 的 xib 文件中的文件检查器中关闭“使用自动布局”。然后您可以使用 setFrame 或 setBounds 方法更改高度。

关于xcode - 调整 UICollectionView 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13017528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com