Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding subview inside UICollectionView Xcode [closed]

I am Working in UICollectionView added my Device Photos inside UICollectionViewCell, now I want to create subview inside my UICollectionView. Please suggest to me how to add subview inside UICollectionViews. Need any code or links.

like image 602
user241641 Avatar asked Dec 01 '22 17:12

user241641


1 Answers

Adding a subview is as simple as,

//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)];

The above code will add a subview at top of collectionView. Is this what you are looking for? If not please provide more details in your question.

like image 61
Amar Avatar answered Dec 14 '22 14:12

Amar