天天看点

为UIView及其子类添加圆角边框

//设置圆角边框

someView.layer.cornerRadius = 8;

someView.layer.masksToBounds = YES;

//设置边框及边框颜色

someView.layer.borderWidth = 8;

someView.layer.borderColor =[ [UIColor grayColor] CGColor];

说明:

①     someView  表示UIView及其之类;

②     必须引入:#import<QuartzCore/QuartzCore.h>

转载:http://mmz06.blog.163.com/blog/static/1214169620114261190392/

圆角: imageView . layer . cornerRadius = 5 ; //(值越大,角就越圆) imageView . layer . masksToBounds = YES ;   边框: [ imageView . layer setBorderWidth : 1 ] ; imageView . layer . borderColor = [ [ UIColor colorWithRed : 226 / 255.0                                                        green : 230 / 255.0 blue : 232 / 255.0 alpha : 1 ] CGColor ] ;   阴影:                                      [ imageView . layer setShadowOffset : CGSizeMake ( 2 , 2 ) ] ; [ imageView . layer setShadowRadius : 5 ] ; [ imageView . layer setShadowOpacity : 1 ] ; [ imageView . layer setShadowColor : [ UIColor blackColor ] . CGColor ] ;

转载:天狐博客 » ios 图片等view layer的圆角,边框,阴影设置