简体   繁体   中英

corner radius on layer and shadows

I have a map view inside a cell and I want it to have corner radius and shadow. I either get only rounded corners OR only the shadow and no rounder corners when i set masks to bounds ON/OFF respectively. I looked up to this example: Can't add a corner radius and a shadow

but with no success. What am I missing? thank you in advance!

[[cell.map1 layer] setShadowColor:[UIColor blackColor].CGColor];
[[cell.map1 layer] setShadowOpacity:0.8f];
[[cell.map1 layer] setShadowRadius:20.0f];
[[cell.map1 layer] setShadowOffset:CGSizeMake(0, 3)];
       // [[cell.map1 layer] setMasksToBounds:NO];
[[cell.map1 layer] setShouldRasterize:YES];
[[cell.map1 layer] setCornerRadius:20];

Setting mask to bounds is like setting clip to bounds. This means nothing can be outside the bounds and the shadow lays outside of the bounds. Check out this post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM