1. 程式人生 > >iOS view的圓角和陰影並存

iOS view的圓角和陰影並存

 UIView *v=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
    v.backgroundColor=[UIColor yellowColor];
    //v.layer.masksToBounds=YES;這行去掉
    v.layer.cornerRadius=10;
    v.layer.shadowColor=[UIColor redColor].CGColor;
    v.layer.shadowOffset=CGSizeMake(10, 10);
    v.layer.shadowOpacity=0.5;
    v.layer.shadowRadius=5;

    [self.view addSubview:v];

效果如下