2011-03-11 37 views
1

嘿,我製造具有顯示在分組的tableview的頂部的大圖像的應用程序,我不希望圖像在TableCell的,因爲它看起來愚蠢的方式。我只是想形象漂浮在那裏,但我不知道該怎麼辦呢?謝謝!圖片在的tableview的頂部

回答

1

使用表格視圖的tableHeaderView屬性,像這樣:

UIImageView *topImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my logo.png"]; 
topImage.backgroundColor = [UIColor clearColor]; 
topImage.frame = CGRectMake(0, 0, theTableView.bounds.size.width, 100); // replace 100 with the height of your image, plus a bit if you want it to have a margin 
topImage.contentMode = UIViewContentModeCenter; 

theTableView.tableHeaderView = topImage; 
[topImage release]; 
+0

驚人!謝謝! – 2011-03-11 20:18:49