Search code examples
cocoaikimagebrowserview

Changing selection state of IKImageBrowserView


Hey guys, I've just migrated my image selector from NSCollectionView to IKImageBrowserView. I've got almost everything set up the way I want it, except for the selection ring. I don't like the greyed out background that IKImageBrowserView defaults to, and I wanted to do a yellow stroke around the edge of my selected image to indicate it's selection (like in iPhoto). Is is possible to override the draw state of IKImageBrowserCell? I haven't been able to find any way to do it yet. It doesn't have the simple drawRect methods that I'm used to. Any help would be appreciated. I'm assuming I have to use CALayers?

I overrode - (CALayer *)layerForType:(NSString *)type and tried just as a test, setting the layer corner radius to 0, but it didn't seem to change anything. The method is being called because if I throw a breakpoint in it, it stops there. However, even if I return nil from that method, it still draws the images like usual.

Thanks!


Solution

  • That is the right method for customizing the IKImageBrowserCell.

    Using CALayers and configuring different attributes, you can control many facets of how the images are presented.,

    A layer of type = IKImageBrowserCellSelectionLayer is what you will want to change to have the display behave and present as you wish.

    Here's a link to Apple's sample code project that will get you started