//1.圆角
//只给父层倒圆角无效
imgView.layer.cornerRadius= 100;
//此属性可以让UIImageView的所有子图层父图层一起变化
//imgView.layer.masksToBounds = YES;
//2.阴影
imgView.layer.shadowColor= [UIColor blueColor].CGColor;
imgView.layer.shadowOffset= CGSizeMake(10, 10);
imgView.layer.shadowOpacity = 0.8;
//3.设置transform,形变
//(1)平移
imgView.layer.transform= CATransform3DMakeTranslation(0, -100, 0);
//(2)旋转
//沿哪个轴旋转值就为1
imgView.layer.transform= CATransform3DMakeRotation(M_PI, 0, 0, 1);
//(3)缩放
imgView.layer.transform= CATransform3DMakeScale(0.5, 1, 1);
//Documents中搜索transform3D来获取keyPath
//向上移动100
[imgView.layersetValue:@-100 forKeyPath:@"transform.translation.y"];
沿z轴逆时针旋转45度
[imgView.layersetValue:@-M_PI_4 forKeyPath:@"transform.rotation.z"];
//自定义CALayer
//1.必须把自定义的层添加到父图层上去显示。
[self.view.layeraddSublayer:myLayer];
//2.设置图层的显示属性
//尺寸和颜色
myLayer.bounds =CGRectMake(0, 0, 200, 200);
myLayer.backgroundColor =[UIColor redColor].CGColor;
//显示位置,默认为中心点,具体位置由锚点决定。
myLayer.position =CGPointMake(100, 100);
//锚点,默认值为0.5,0.5
myLayer.anchorPoint =CGPointMake(0.5, 0.5);
//position和anchorPoint的值决定了层的显示位置。
//Layer在放大缩小时是以锚点为中心点进行放大缩小的。
UIImage *image = [UIImage imageNamed:@"2012100413195471481.jpg"];
myLayer.contents = (id)image.CGImage;
//淡入淡出动画,改变layer的透明度,范围是0到1。myLayer.opacity
//self.view.layer是rootLayer,无隐式动画效果。//所有的非rootLayer存在隐式动画效果。