UIView設(shè)置陰影CALayer的屬性:
shadowColor那婉,
shadowOffset赐稽,
shadowOpacity叫榕,
shadowRadius,
shadowPath
加陰影
//shadowColor陰影顏色
_imageView.layer.shadowColor = [UIColor blackColor].CGColor;
/**
shadowOffset陰影偏移,x向右偏移4,y向下偏移4姊舵,默認(rèn)(0, -3),這個(gè)跟shadowRadius配合使用
*/
_imageView.layer.shadowOffset = CGSizeMake(4,4);
//陰影透明度晰绎,默認(rèn)0
_imageView.layer.shadowOpacity = 0.8;
//陰影半徑,默認(rèn)3
_imageView.layer.shadowRadius = 4;
//shadowColor陰影顏色
_imageView1.layer.shadowColor = [UIColor yellowColor].CGColor;
shadowOffset陰影偏移括丁,默認(rèn)(0, -3),這個(gè)跟shadowRadius配合使用
//陰影透明度荞下,默認(rèn)0
_imageView1.layer.shadowOffset = CGSizeMake(0,0);
_imageView1.layer.shadowOpacity = 1;
// 陰影半徑,默認(rèn)3
_imageView1.layer.shadowRadius = 3;
//路徑陰影
UIBezierPath *path = [UIBezierPath bezierPath];
float width = _imageView1.bounds.size.width;
float height = _imageView1.bounds.size.height;
float x = _imageView1.bounds.origin.x;
float y = _imageView1.bounds.origin.y;
float addWH = 10;
CGPoint topLeft = _imageView1.bounds.origin;
CGPoint topMiddle = CGPointMake(x+(width/2),y-addWH);
CGPoint topRight = CGPointMake(x+width,y);
CGPoint rightMiddle = CGPointMake(x+width+addWH,y+(height/2));
CGPoint bottomRight = CGPointMake(x+width,y+height);
CGPoint bottomMiddle = CGPointMake(x+(width/2),y+height+addWH);
CGPoint bottomLeft = CGPointMake(x,y+height);
CGPoint leftMiddle = CGPointMake(x-addWH,y+(height/2));
[path moveToPoint:topLeft];
//添加四個(gè)二元曲線
[path addQuadCurveToPoint:topRight controlPoint:topMiddle];
[path addQuadCurveToPoint:bottomRight controlPoint:rightMiddle];
[path addQuadCurveToPoint:bottomLeft controlPoint:bottomMiddle];
[path addQuadCurveToPoint:topLeft controlPoint:leftMiddle];
//設(shè)置陰影路徑
_imageView1.layer.shadowPath = path.CGPath;
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者