1、在iOS中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮、一个文本框、一个Label,一 个图片等等,这些都是UIView
2、其实UIView之所以能显示在屏幕上,完全是应为它内部的一个图层layer
3、在创建UIView对象时,UIView内部会自动创建一个图层(CALayer),即UIView的layer属性
4、当UIView需要显示到屏幕上时,会调用drawRect方法进行绘图,并且会将所有内容绘制在自己的图层 上,绘图完毕后,系统会将图层拷贝到屏幕上,于是就完成了UIView的显示
(绘图上下文是Layer Graphics Context)
5、UIView本身不具备显示功能,是它内部的层才有显示功能
2.1 CALayer的常见属性
@property CGFloat borderWidth;
@property CGColorRef borderColor;
@property CGColorRef backgroundColor; //背景颜色
@property float opacity;//透明度
@property CGColorRef shadowColor; //阴影颜色
@property float shadowOpacity;
@property CGSize shadowOffset;
@property CGFloat shadowRadius;
@property(strong) id contents;
@property CGFloat cornerRadius;
@property CGRect bounds;
@property CGPoint position;
@property CGPoint anchorPoint;
@property CATransform3D transform;
@property(getter=isHidden) BOOL hidden;
@property(readonly) CALayer *superlayer;
@property(copy) NSArray *sublayers;
@property BOOL masksToBounds;