使用渐变背景设置UITableViewCells样式 [英] Styling UITableViewCells with gradient backgrounds

查看:91
本文介绍了使用渐变背景设置UITableViewCells样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找方法来提高我的iPhone应用程序的整体吸引力。大多数功能发生在UITableView中。我想我可以开始添加微妙的梯度到UITableViewCells,因为这似乎提高了一个数量级的应用程序的感觉。选择合适的字体/大小也有很大的帮助。我的问题,这个论坛是,什么是最好的策略添加渐变到UITableViewCells?你使用Core Graphics / Quartz吗?您使用1x1像素图像并拉伸它吗?我对Tumblr iPhone应用程序的以下屏幕截图有些兴趣: http://dl-client.getdropbox.com/u/57676/screenshots/tumblr.jpg

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

有没有人有任何好的例子如何让你的UITableViewCell伸出来?

Does anyone have any good examples of how to make your UITableViewCell's stick out?

出于性能原因,最好使用图像或绘制与Quartz?如果是Quartz,我想看看一些示例代码如何将渐变绘制到单元格中。

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.

谢谢。

推荐答案

我为Tumblr工作,虽然我没有写iPhone应用程序(

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.

-tableView:cellForRowAtIndexPath:

In -tableView:cellForRowAtIndexPath:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackgroundSelected.png"]];

很简单,真的:UIImageView中的PNG图像作为单元格的背景视图。

Pretty simple, really: PNG images in a UIImageView as the cell's background views.

这两张图片是1x61纵向渐变,UIKit会自动横向扩展以适合单元格的宽度。

The two images are 1x61 vertical gradients that UIKit automatically stretches horizontally to fit the width of the cell.

这篇关于使用渐变背景设置UITableViewCells样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆