What's the difference between a CoreAnimation Layer Backed View and a Layer Hosting View?

本秂侑毒 提交于 2019-12-18 10:27:27

问题


What is the difference between a Layer Backed View and a Layer Hosting View in Core Animation?

What are the steps to setting up each and when is it appropriate to use either type?


回答1:


A layer backed view contains Cocoa or Cocoa Touch UI controls and can be animated using the animator proxy. Layer backed views allow you to animate your UI and help to reduce the overhead of drawing by caching the views contents on a core animation layer. Create a Layer backed view by setting the wants layer property:

NSView *layerBacked = [NSView new];
[layerBacked setWantsLayer:YES];

A layer hosting view provides a layer for direct manipulation hosted by an NSView or UIView. Layer hosting views can be used for embedding core animation drawing and animation anywhere you can put an NSView:

NSView *layerHosting = [NSView new];
[layerHosting setLayer:[[CALayer new] autorelease]];
[layerHosting setWantsLayer:YES];


来源:https://stackoverflow.com/questions/351503/whats-the-difference-between-a-coreanimation-layer-backed-view-and-a-layer-host

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