Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
599 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...