关于CALayer层的一些简单知识

来源:互联网 发布:淘宝假冒申诉 编辑:程序博客网 时间:2024/06/05 23:08

@property (strong, nonatomic) IBOutlet UIView *customView;

//设置边框的宽度为5

self.customView.layer.borderWidth = 5;


//设置边框的颜色

self.customView.layer.borderColor = [UIColor greenColor].CGColor;


//设置layer的圆角

self.customView.layer.cornerRadius = 20;


//view的图层上添加一个imagecontents表示接受内容

self.customView.layer.contents = (id)[UIImage imageNamed:@"123.jpg"].CGImage;


//设置超出主图层的部分把它给剪切掉

self.customView.layer.masksToBounds = YES;


/**

 *  如果设置了超过主图层的部分减掉,则设置阴影不会有显示效果。

 */

//设置阴影的颜色

self.customView.layer.shadowColor = [UIColor blackColor].CGColor;

//设置阴影的偏移量,如果为正数,则代表为往右边偏移

self.customView.layer.shadowOffset=CGSizeMake(15, 5);

//设置阴影的透明度(0~1之间,0表示完全透明)

self.customView.layer.shadowOpacity=0.6;


0 0
原创粉丝点击