What are the differences between a UIView and a CALayer?

后端 未结 6 2164
天命终不由人
天命终不由人 2020-12-04 05:42

Both have most of the same attributes, both support different kind of animations, both represent different data. What are the differences between a UIView and a CALayer?

6条回答
  •  遥遥无期
    2020-12-04 06:01

    UIView is a container for CALayers. Using UIKit.

    CALayer where we draw the contents. Using CoreGraphics

    If you work with custom control like features it would be great to go ahead with single view containing more layers for accurate native rendering. Since CALayers are weightless than UIView.

    To create common skeleton for Mac and iOS, follow the design for your app using CALayers. Since it is available in both platform.

    UIView having feature like touch events achieved using delegates -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event, tochesStart like events and other UIKit features.

    To work with CALayers use Core Graphics knowledge.For any simple view rendering UIView is enough.

提交回复
热议问题