使用渐变背景设计UITableViewCells [英] Styling UITableViewCells with gradient backgrounds
问题描述
有没有人有什么好的例子为了让你的UITableViewCell伸出手来?
出于性能原因,最好使用图形或使用Quartz绘图?如果是Quartz,我希望看到一些示例代码,让人们将渐变绘制到单元格中。
谢谢。
我为Tumblr工作,虽然我没有写iPhone应用程序(他做了),我有源码,可以告诉你如何完成。
在 -tableView:cellForRowAtIndexPath: code>
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@postCellBackground.png ]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@postCellBackgroundSelected.png]];
很简单,真的:在UIImageView中的PNG图像作为单元格的背景视图。
两个图像是1x61垂直渐变,UIKit自动水平延伸以适应单元格的宽度。
I've been looking for ways to improve the overall attractiveness of my iPhone applications. A majority of the functionality happens in UITableView. I think I can start by adding subtle gradients to UITableViewCells, as that seems to improve the feel of the app by an order of magnitude. Selecting the appropriate fonts/sizes helps a great deal also. My question for this forum is, what's the best strategy of adding gradients to UITableViewCells? Are you using Core Graphics/Quartz? Are you using a 1x1 pixel image and stretching it? I'm interesting in something along the lines of the following screenshot of the Tumblr iPhone app: http://dl-client.getdropbox.com/u/57676/screenshots/tumblr.jpg
Does anyone have any good examples of how to make your UITableViewCell's stick out?
And for performance reasons is it better to use an image or draw with Quartz? If Quartz, I'd love to see some sample codes of how folks are drawing the gradients into the cells.
Thanks.
I work for Tumblr, and while I didn't write the iPhone app (he did), I have the source and can tell you how it's done.
In -tableView:cellForRowAtIndexPath:
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackgroundSelected.png"]];
Pretty simple, really: PNG images in a UIImageView as the cell's background views.
The two images are 1x61 vertical gradients that UIKit automatically stretches horizontally to fit the width of the cell.
这篇关于使用渐变背景设计UITableViewCells的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!