uiview
的阴影设置主要通过uiview
的layer
的相关属性来设置
阴影的颜色
1
|
imgview.layer.shadowcolor = [uicolor blackcolor].cgcolor;
|
阴影的透明度
1
|
imgview.layer.shadowopacity = 0.8f;
|
阴影的圆角
1
|
imgview.layer.shadowradius = 4.f;
|
阴影偏移量
1
|
imgview.layer.shadowoffset = cgsizemake(4,4);
|
1
|
imgview.layer.shadowoffset = cgsizemake(0,0);
|
其实从偏移量上可以看出来,即使偏移量为(0,0)时,围绕view的四周依然能看到一定阴影。
阴影的路径
除了通过上面的操作,我们还可以设定阴影的路径
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
//路径阴影
uibezierpath *path = [uibezierpath bezierpath];
[path movetopoint:cgpointmake(-5, -5)];
//添加直线
[path addlinetopoint:cgpointmake(paintingwidth /2, -15)];
[path addlinetopoint:cgpointmake(paintingwidth +5, -5)];
[path addlinetopoint:cgpointmake(paintingwidth +15, paintingheight /2)];
[path addlinetopoint:cgpointmake(paintingwidth +5, paintingheight +5)];
[path addlinetopoint:cgpointmake(paintingwidth /2, paintingheight +15)];
[path addlinetopoint:cgpointmake(-5, paintingheight +5)];
[path addlinetopoint:cgpointmake(-15, paintingheight /2)];
[path addlinetopoint:cgpointmake(-5, -5)];
//设置阴影路径
imgview.layer.shadowpath = path.cgpath;
|
总结
以上就是这篇文章的全部内容,希望能对各位ios开发者们能有所帮助,如果有疑问大家可以留言交流。
原文链接:http://www.jianshu.com/p/575ce7d7b68f