---
title: "iphone开发--大区域中平铺(非拉伸)图片"
author: "lpluck08"
date: "2012-11-10T22:14:50Z"
tags: []
categories: ["移动开发"]
slug: "iphone"
draft: false
lastmod: "2012-11-29T12:02:50Z"
id: 1722326
url: "https://apluck.iteye.com/blog/1722326"
---

创建一个UIView的子类，在- (void)drawRect:(CGRect)rect中写入

\[\[UIImage imageNamed:@"123.png"] drawAsPatternInRect:rect];

 

并在- (id)initWithFrame:(CGRect)frame中写入

```
[self setBackgroundColor:[UIColor clearColor]];
[self setNeedsDisplay];
```

 

在调用的地方直接调用- (id)initWithFrame:(CGRect)frame即可。