ShaunArchibald
ShaunArchibald

Reputation: 59

Changing collectionview button's image in Cocoa

Tools: xCode, Objective-C, Mac, Cocoa

Purpose: I am creating a collection view with many buttons. Each button opens a file in a folder and each of them has a background picture of the file (for example: jpeg file) so it looks like what you would see in a folder.

Question: How to make each button have a different image? Also, is this too difficult for a beginner?

P.S. : If i did this without the collectionview option, I would just drag the button on xib and change their background images, however I need my window to be collapsable and scrollable, hence I am using the collection view.

I would very much appreciate any comments/help/answers. Thanks!

Upvotes: 0

Views: 129

Answers (1)

harryhorn
harryhorn

Reputation: 912

This should not be difficult. A CollectionView holds a collection of CollectionViewItems. Inside the Item you can create any views you need. One of them could be an NSImageView that you set at runtime to the image you like. I suggest to play around with CollectionView and some f the samples Apple provides on it.

Upvotes: 1

Related Questions