---
title: "添加阴影和设置圆角"
author: "mrjeye"
date: "2011-07-07T15:08:59Z"
tags: ["圆角", "阴影"]
categories: ["移动开发"]
slug: "untitled"
draft: false
lastmod: "2011-07-07T15:08:59Z"
id: 1118819
url: "https://mrjeye.iteye.com/blog/1118819"
---

圆角:


```java

	CALayer * layer = [theview layer];
	
	[layer setmaskstobounds:yes];
	[layer setcornerradius:theradius];
	[layer setborderwidth:theborderwidth];
	[layer setbordercolor:thecolor.cgcolor];

```


其中:theView(UIView)为目标view
theRadius(float)为圆角半径
theBorderWidth(float)为边框大小
theColor(UIColor)为边框颜色

---------------------------我割---------------------------

阴影:


```java

	CALayer * layer = [theview layer];
	
	[layer setshadowoffset:theoffset];
	[layer setshadowradius:theradius];
	[layer setshadowopacity:theopacity];
	[layer setshadowcolor:thecolor.cgcolor];

```


其中:theView(UIView)为目标view
theOffset(CGSize)为阴影偏移量,默认为(0, -3)
theRadius(float)为阴影四角圆角半径,默认值为3
theOpacity(float)为阴影透明度(取值为)
theColor(UIColor)为阴影颜色