為一個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