---
title: "ios iphone UITableView"
author: "ynial"
date: "2011-11-23T00:32:05Z"
tags: []
categories: ["移动开发"]
slug: "ios-iphone-uitableview"
draft: false
lastmod: "2011-11-23T00:32:05Z"
id: 1273252
url: "https://ynial.iteye.com/blog/1273252"
---

UITableView

1：如果一个类继承了 UITableView 那么怎么处理这个UITableView的背景图片呢？


```objective-c

    self.backgroundView = [[uiimageview alloc] initWithImage:[uiimage imagenamed:imagename]];

```


原来是这样处理的


```objective-c

self.backgroundColor = [uicolor colorwithpatternimage:[uiimage imagenamed:imagename]];

```


但是一旦这样处理背景图片 当这个表格和屏幕顶部有间距的时候 背景图片会串位置。



```objective-c

self.backgroundColor = [uicolor colorwithpatternimage:[uiimage imagenamed:imagename]];

```



那么怎么让当前的tableView和屏幕顶端有间距呢？


```objective-c

    //actualTop is margin top value
    [self setcontentinset:uiedgeinsetsmake(actualtop,0,0,0)];

```