I have a UITableViewController that has a background image. I am setting the image for the tableview like this:
[self.view setBackgroundColor: [UIColor colorWithPatternImage:
[UIImage imageWithContentsOfFile:
[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:
@"background1.jpg"]]]];
The problem is, each of 开发者_开发知识库my custom tableview cells get the same background image--it's repeated in each cell. As a test, I tried making everything in my cell transparent with an alpha of 0.0, but even then although I can't see any of the labels in each cell, I still see the background image repeated in each cell:
cell.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
cell.contentView.alpha = 0.0;
cell.alpha = 0.0;
Any suggestions on how to get my table's background image to stop repeating in each cell would be appreciated!
Have you tried setting the opaque
property to NO
? It's defined in NSView
.
[cell setOpaque:NO];
It's defined in the Apple API as follows:
YES if it is opaque; otherwise, NO. If opaque, the drawing operation assumes that the view fills its bounds and can draw more efficiently. The results are unpredictable if opaque and the view doesn’t fill its bounds. Set this property to NO if the view is fully or partially transparent. The default value is YES.
精彩评论