Alternative method for canDrawSubviewsIntoLayer prior to OSX 10.9

喜欢而已 提交于 2019-12-24 21:36:05

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/24835853/alternative-method-for-candrawsubviewsintolayer-prior-to-osx-10-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!