为一个UIview 添加阴影:
UIView *shadow = [[UIView alloc] initWithFrame:CGRectMake(30, 30, 100, 100)];
shadow.backgroundColor = [UIColor whiteColor];
shadow.layer.shadowColor = [UIColor blackColor].CGColor;//shadowColor阴影颜色
shadow.layer.shadowOffset = CGSizeMake(4,0);//shadowOffset阴影偏移,x向右偏移4,y向下偏移4,默认(0, -3),这个跟shadowRadius配合使用
shadow.layer.shadowOpacity = 0.8;//阴影透明度,默认0
shadow.layer.shadowRadius = 4;//阴影半径,默认3
网友评论