我正在使用UICollectionView
,将设备中的照片添加到UICollectionViewCell
中,现在我想在UICollectionView
中创建子视图。请建议如何在UICollectionViews
中添加subview
。需要任何代码或链接。
我正在使用UICollectionView
,将设备中的照片添加到UICollectionViewCell
中,现在我想在UICollectionView
中创建子视图。请建议如何在UICollectionViews
中添加subview
。需要任何代码或链接。
添加一个子视图就像这样简单,
//Create subview
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.collectionView.frame.size.width, 20)];
//Add
[collectionView addSubview:subview];
//Bring to front so that it does not get hidden by cells
[collectionView bringSubviewToFront:subview];
//This will shift collectionView content down by 20px at top
[collectionView setContentInset:UIEdgeInsetsMake(subview.frame.size.height, 0, 0, 0)];
以上代码将在collectionView顶部添加一个子视图。如果这不是您想要的,请在问题中提供更多细节。