iOS 给UIView 设置阴影shadow

    UIView *v = [[UIView alloc]init];
    v.frame = CGRectMake(100, 100, 100, 100);
    v.backgroundColor = [UIColor yellowColor];
    v.layer.shadowColor = [UIColor blackColor].CGColor;
    v.layer.shadowOffset = CGSizeMake(0, -3);//shadowOffset阴影偏移,x向右偏移4,y向下偏移4,默认(0, -3),这个跟shadowRadius配合使用
    v.layer.shadowRadius = 4;//阴影半径,默认3
    v.layer.shadowOpacity = 0.8;//阴影透明度,默认0
    [self.view addSubview:v];

你可能感兴趣的:(iOS 给UIView 设置阴影shadow)