Search code examples
objective-ccocoacalayernsimagensimageview

Alternative method for canDrawSubviewsIntoLayer prior to OSX 10.9


I needed to implement the following code in my image view to make a gif properly animate:

self.homeView.radarImageView.animates = YES;
self.homeView.radarImageView.canDrawSubviewsIntoLayer = YES;
self.homeView.radarImageView.image = currentData.radarImage;

Unfortunately, the canDrawSubviewsIntoLayer method is not compatible with OSX prior to 10.9. Is there an alternative approach that I can use that will make this work in OSX 10.7 and higher?


Solution

  • avoid layer-based views under 10.8 and below as they don't seem to mix well with animated gifs

    see: How to display animated GIF in Objective C on top of the layered View?

    edit:

    as asked in the comment, one can draw gradients (and all other effects without using layers)
    For Gradients for example there is NSGradient that takes NSColors and can fill a rect

    shameless plug:

    A NSView that can draw all that you ever want in your background: color, gradient, patttern image, just an image, a border, rounded corners... all in one view https://github.com/Daij-Djan/DDBackgroundView