iOS 控件加阴影

来源:互联网 发布:淘宝店铺装修招牌尺寸 编辑:程序博客网 时间:2024/05/19 16:49

下面以给cell加阴影为例介绍加阴影的方法

self.contentView.backgroundColor = [UIColor whiteColor];    self.contentView.layer.shadowColor = [UIColor blackColor].CGColor;    //阴影的角度,分别是靠右和靠下。    self.contentView.layer.shadowOffset = CGSizeMake(0, 10);    self.contentView.layer.shadowRadius = 1.0;    self.contentView.layer.shadowOpacity = 0.8;    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.contentView.bounds cornerRadius:1.0];    self.contentView.layer.shadowPath = path.CGPath;

具体的参数,可以自己尝试调整,实现很简单,调整起来,也是非常的简单。