---
title: "Create rounded UIViews with shadow"
author: "zani"
date: "2011-10-22T21:46:44Z"
tags: []
categories: ["移动开发"]
slug: "create-rounded-uiviews-with-shadow"
draft: false
lastmod: "2011-10-22T23:05:55Z"
id: 1207884
url: "https://zani.iteye.com/blog/1207884"
---

```
[roundedView setBackgroundColor:[UIColor blackColor]];
 
	[[roundedView layer] setCornerRadius:8];
	[[roundedView layer] setMasksToBounds:NO]; 
	[[roundedView layer] setShadowColor:[UIColor blackColor].CGColor];
	[[roundedView layer] setShadowOpacity:1.0f];
	[[roundedView layer] setShadowRadius:6.0f];
	[[self layer] setShadowOffset:CGSizeMake(0, 3)];
```

 

关键是要把 maskstobounds设置为NO