UITableView背景图片Alpha问题 [英] UITableView background image alpha problems

查看:99
本文介绍了UITableView背景图片Alpha问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有UITableView的UIView用于子视图. UIView通过setBackGroundColor将图像应用于背景,并且我以相同的方式将背景应用于UITableView.这两张图片都是PNG,并且UITableView的背景中的透明度似乎不起作用-PNG似乎是在不考虑其中的透明度数据的情况下呈现的-我应该看到背景通过它的UIView.我用于应用背景图像的基本代码是:

I have a UIView with a UITableView for a subview. The UIView has an image applied to its background via setBackGroundColor, and I have applied a background to the UITableView in the same manner. Both images are PNGs, and the the background for the UITableView has levels of transparency in it that don't appear to be working -- the PNG seems to be rendered without regard to the transparency data within it -- I should be seeing the background of the UIView through it. The basic code I am using for applying the background images is:

UIImage *patternImage = [UIImage imageNamed:@"background.png"];
[tableContainer setBackgroundColor:[UIColor colorWithPatternImage: patternImage]];

我很困惑.有什么想法吗?

I'm stumped. Any ideas?

推荐答案

您需要确保表格视图不透明.

You need to make sure your table view is not opaque.

在Interface Builder中,取消选中表视图的不透明"设置.或者,在代码中,

In Interface Builder, uncheck your table view's 'Opaque' setting. Or, in code,

tableView.opaque = NO;

请记住,关于表视图的任何类型的透明性都会大大降低性能.如果只有几行,则可能会没事,但是如果进行任何滚动,则要做好一些准备.发布之前,请确保在真实设备上进行测试.

Keep in mind that any sort of transparency in regard to table views will slow performance dramatically. If you only have a few rows, you'll probably be OK, but if you do any scrolling, be prepared for some pain. Make sure you test on a real device before release.

这篇关于UITableView背景图片Alpha问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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