CoreAnimation层支持视图和层主机视图有什么区别? [英] What's the difference between a CoreAnimation Layer Backed View and a Layer Hosting View?

查看:89
本文介绍了CoreAnimation层支持视图和层主机视图有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

核心动画中的层支持视图和层主机视图之间的区别是什么?

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?

推荐答案

图层支持视图包含Cocoa或Cocoa Touch UI控件,可以使用animator代理进行动画处理。层支持的视图允许您为UI设置动画,并通过在核心动画层上缓存视图内容来帮助减少绘制的开销。通过设置想要的图层属性创建一个图层支持的视图:

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

层主机视图提供了一个由NSView或UIView托管的直接操作层。层主机视图可以用于在任何可以放置NSView的地方嵌入核心动画绘制和动画:

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

这篇关于CoreAnimation层支持视图和层主机视图有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆