frameForItem(at:withNumberOfItems:)
Returns the frame of an item based on the number of items in the collection view.
Declaration
func frameForItem(at index: Int, withNumberOfItems numberOfItems: Int) -> NSRectParameters
- index:
The index of the item in the collection view.
- numberOfItems:
The targeted number of items in the collection view. Use this parameter to specify the number of items you intend to have in the collection view, if that number is different than the actual number of items.
Return Value
The frame rectangle that reflects where the collection view would place the item.
Discussion
Using the value in the numberOfItems parameter, this method calculates the frame rectangle of the item at the specified index in the collection view.
When the collection view is a drag destination, use this method (instead of the content method) to get the frame of items. Drag operations can change the number of items, which affects the layout of the item views.