Questions tagged [uicollectionviewlayout]

The UICollectionViewLayout class is an abstract base class that is used to generate layout information for a collection view.

The UICollectionViewLayout class is an abstract base class that you subclass and use to generate layout information for a collection view. The job of a layout object is to determine the placement of cells, supplementary views, and decoration views inside the collection view’s bounds and to report that information to the collection view when asked. The collection view then applies the provided layout information to the corresponding views so that they can be presented onscreen.

More: UICollectionViewLayout Class Reference

1496 questions
26
votes
5 answers

UICollectionView contentOffset changes with custom layout

I have a UICollectionView with a custom UICollectionViewLayout (actually, I'm using this nice layout). I set contentOffset = CGPointZero in viewDidLoad. After viewDidLoad, however, the offset is -20, and the content gets pushed down like so: (It…
Evan Cordell
  • 4,108
  • 2
  • 31
  • 47
25
votes
6 answers

UICollectionView custom line separators

I wanna making 2pt black separators in UICollectionView for our new app. Screenshot from our app is below. We couldn't use UITableView, because we have custom insert/delete animations, scrolling and parallax effects and so on.
25
votes
3 answers

Unable to change background color on UICollectionView (iOS)

I'm writing my first iOS app and I seam to be having some problems in changing the backgroundColor of a UICollectionView. The app has a navigation controller and certain views. Initially, I was able to change the color in my AppDelegate…
23
votes
2 answers

iOS 10/11 UICollectionViewFlowLayout using UICollectionViewFlowLayoutAutomaticSize results in footer supplementary view misaligned

So this is an interesting issue we found with UICollectionViewFlowLayout on iOS 10 (still an issue on 11) and using UICollectionViewFlowLayoutAutomaticSize for the estimatedItemSize. We've found that using UICollectionViewFlowLayoutAutomaticSize for…
dlbuckley
  • 685
  • 1
  • 5
  • 14
23
votes
7 answers

UICollectionView with two headers

Having two headers in UICollectionView? I've got a UICollectionView which uses the flow layout, which also has a header and footer: --------- | head | --------- | A | B | --------- | C | D | --------- | foot | --------- Occasionally, I'd like…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
23
votes
7 answers

UICollectionViewFlowLayout not invalidating right on orientation change

i have a UICollectionView with a UICollectionViewFlowLayout. I also implement the UICollectionViewDelegateFlowLayout protocol. In my datasource i have a bunch of UIViewControllers which respond to a custom protocol so i can ask for their size and…
xxtesaxx
  • 6,175
  • 2
  • 31
  • 50
23
votes
5 answers

UICollectionView scrolling in both directions

I made a UICollectionView with a vertical scroll. The width of the cell is more than than the screen width, so I created a customFlowLayout based on UICollectionViewFlow layout returning the right calculated content size. However, this doesn't…
last-Programmer
  • 985
  • 3
  • 9
  • 19
22
votes
10 answers

UICollectionView sticky header in swift

I'm trying to create a sticky supplementary header, which stays on top all the time and won't response to scrolling events. The solutions I found so far still react on bounch scrolling and are fixed using a custom flowLayout, which will probably be…
Antoine
  • 23,526
  • 11
  • 88
  • 94
21
votes
8 answers

Assertion Failure in UICollectionViewData validateLayoutInRect on ios7

Assertion Failure in UICollectionViewData validateLayoutInRect on iOS7. I am trying to delete all UICollectionView items, one by one, using a for loop; I posted my code below. I delete the UICollectionView items using deleteItemsAtIndexPaths. It's…
user1888996
  • 271
  • 1
  • 3
  • 6
21
votes
3 answers

Animate frame and layout change of UICollectionView

I am trying to create an effect where I change the layout of my UICollectionView while changing the frame size Initially the collectionView layout presents a "thumbnail" gallery style full screen. After resizing the frame to a thin strip - I would…
Avba
  • 14,822
  • 20
  • 92
  • 192
21
votes
1 answer

UICollectionView special horizontal flow - multiple sections

I have a UICollectionView there is used differently depending on device orientation. The image describe what I have and what I need. Is it possible to get "Horizontal scrolling as I need it" with default flowlayout or do I need to make…
21
votes
7 answers

Placing a margin around each edge of the UICollectionView

When the UICollectionView is populated with items they always go right to the edges of the UICollectionView like so: --------------- |X X X X X X X| |X X X X X X X| |X X X X X X X| |X X X X X X X| |X X X X X X X| |X X X X X X X| --------------- I…
Adam
  • 2,123
  • 4
  • 17
  • 25
21
votes
2 answers

Delete cell from UICollectionView without reloading from top

I am using a CollectionView in my ios app. Each collection cell contains a delete button. By clicking the button the cell should be deleted. After deletion, that space will be filled with below cell (I don't wish to reload the CollectionView and…
19
votes
2 answers

UICollectionView horizontal paging with space between pages

I'm looking for a way to replace the native UIPageViewController horizontal paging with a UICollectionView. so far i did the following: let layout = UICollectionViewFlowLayout() layout.scrollDirection = .horizontal layout.itemSize =…
Eyal
  • 10,777
  • 18
  • 78
  • 130
18
votes
2 answers

align single UICollectionViewCell to the left of the collectionView

I've got a collectionView that is inside a tableView cell. The collectionView has multiple sections. If a section has only one cell, the cell appears centered. How can I align that single cell to the left? The collectionView has the following…