I'd like my IKImageBrowserView to display long titles by wrapping them and displaying them in multiple lines, but I've been unable to achieve this.
I've tried changing the size of the titleFrame returned in the ImageBrowserCell subclass and also setting the paragraph style on the title so that it should wrap (NSLineBreakByWordWrapping) but I only ever get a single line of text.
Has anyone tried this? Any other suggestion I might try?
Not easily, I'm afraid. One way you can do it is by leaving
imageTitleblank and drawing text on aCALayer. I was able to make it work with fairly decent results:First things first -- since you're not going to be using the standard
imageTitleproperty, you want to create a new title property in your<IKImageBrowserItem>-conforming data object. I called mine simplytitle.Then, you want to create an
IKImageBrowserCellsubclass. Make sure to tell yourIKImageBrowserViewyou're using a custom cell; I just wrote a quick category for this:Next, in your custom cell, override the method
- (CALayer *)layerForType:(NSString *)type. Create and return a CALayer for a specific layer location type:Then, implement the
-drawLayer:inContext:method in your custom cell to handle the layer's drawing:Unfortunately, this approach does have a few drawbacks. The text doesn't get a blue selection background like
imageTitledoes. You can, however, draw your own selection background using anNSBezierPathinside a custom CALayer for theIKImageBrowserCellSelectionLayer.Hope this is enough to go on.