xcodecocoaikimagebrowserview

Add a background image to IKImageBrowserView


I have a IKImageBrowserView inside of a NSScrollView that is populated with a bunch of images. How do I add a background image that will scroll with the images in the IKImageBrowserView?

Basically what I am trying to do is create a view similar to the iBooks app on the iPhone with items sitting on a bookshelf.


Solution

  • I was able to achieve the effect I was looking for by implementing the custom ImageBrowserView and ImageBrowserBackgroundLayer classes from the sample project here: http://developer.apple.com/library/mac/#/legacy/mac/library/samplecode/ImageKitDemo/Introduction/Intro.html

    What I did was move the custom ImageBrowserView and ImageBrowserBackgroundLayer classes to my project then set the browserView's background layer to the custom class like this:

    ImageBrowserBackgroundLayer *backgroundLayer = [[ImageBrowserBackgroundLayer alloc] init];
    [browserView setBackgroundLayer:backgroundLayer];
    backgroundLayer.owner = browserView;
    

    Then in interface builder I had to change the scroll view's View class to the custom ImageBrowserView class.