开发者

Changing selection state of IKImageBrowserView

开发者 https://www.devze.com 2023-02-15 08:34 出处:网络
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 grey

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!


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

0

精彩评论

暂无评论...
验证码 换一张
取 消