I want my UITableView to be completely invisible but I have set a lot of things and nothing seems to be working.
I use custom table cells.
This is what I set in the cell.h
self.textLabel.backgroundColor = [UIColor clearColor];
primaryLabel.backgroundColor = [UIColor clearColor];
secondaryLabel.backgroundColor = [UIColor clearColor];
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.backgroundView.backgroundColor = [UIColor clearColor];
self.accessoryView.backgroundColor = [UIColor clearColor];
self.selectedBackgroundView.backgroundColor = [UIColor clearColor];
And I also set
_tableView.backgroundColor = [UIColor clearColor];
But still it is not working, what am I missing?
Instead, you could use the hidden property of the tableView.
tableView.hidden = YES;
With regards to the "incorrect" answer given, I think you mean is that you want the tableView background to disapear (showing the views background).
If so, in your viewDidLoad, add the following: (given you made your tableView programmatically)
[self.tableView setBackgroundColor:[UIColor clearColor]];
If you also don't want to show the lines for each cell:
[self.tableView setSeparatorColor:[UIColor clearColor]];
Related
I have 10 UIButtons that I want to change the background color of.
Here's what I have right now:
b1.backgroundColor = [UIColor redColor];
b2.backgroundColor = [UIColor redColor];
b3.backgroundColor = [UIColor redColor];
b4.backgroundColor = [UIColor redColor];
b5.backgroundColor = [UIColor redColor];
b6.backgroundColor = [UIColor redColor];
b7.backgroundColor = [UIColor redColor];
b8.backgroundColor = [UIColor redColor];
b9.backgroundColor = [UIColor redColor];
b10.backgroundColor = [UIColor redColor];
I wonder if there is another, simpler, way of doing this. I have all ready tried UIButton.backgroundColor = [UIColor redColor] but that didn't work.
//Make an array of the buttons:
NSArray* buttons=[[NSArray alloc] initWithObjects:b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,nil];
//Loop through them
for(UIButton* b in buttons)
{
b.backgroundColor = [UIColor redColor];
}
The array could also be initialized in viewDidLoad.
Put the buttons in an array:
NSArray* buttonArray=[[NSArray alloc] initWithObjects:b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,nil];
Then set the background color for all the buttons:
[buttonArray makeObjectsPerformSelector:#selector(setBackgroundColor:) withObject:[UIColor redColor]];
Create an array of your buttons in viewDidLoad. Then just use a for loop to change colors.
In my UITableViewCell subclass, I'm overriding the setHighlighted and setSelected methods to change the look of the cell when it's selected, but whenever I set the accessoryView property in either of the methods, all my other code that changes the font and shadow colors is ignored entirely.
For example, using this code will change the text color of the text and detail labels
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
if (selected) {
self.textLabel.textColor = [UIColor whiteColor];
self.textLabel.shadowColor = [UIColor clearColor];
self.detailTextLabel.textColor = [UIColor whiteColor];
self.detailTextLabel.shadowColor = [UIColor clearColor];
}
}
But the moment I add the custom accessoryView to the mix, all the other code is ignored, however the accessoryView image does appear.
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
if (selected) {
self.textLabel.textColor = [UIColor whiteColor];
self.textLabel.shadowColor = [UIColor clearColor];
self.detailTextLabel.textColor = [UIColor whiteColor];
self.detailTextLabel.shadowColor = [UIColor clearColor];
self.accessoryView =
[[UIImageView alloc] initWithImage:styleImage(#"/icons/disclosure_selected.png")];
}
}
Is there something I'm doing wrong? How can I properly customize the accessoryView and the rest of the cell's code during the selected and highlighted states?
I ended up just creating my own UIImageView and hiding the built in one.
I think accessoryView is a UIButton not a UIImageView...
Try this :
accessory = [UIButton buttonWithType:UIButtonTypeCustom];
[accessory setImage:[UIImage imageNamed:#"/icons/disclosure_selected.png"] forState:UIControlStateNormal];
accessory.frame = CGRectMake(0, 0, 26, 26); //You can change it
accessory.userInteractionEnabled = YES; //You can change it too
self.accessoryView = accessory;
Hope it'll help
In my application, i am presenting an UITableViewController class (Grouped style) to the user for the particular scenario. I want to show the table view's cells only. The background should be transparent so that the user can see the previous page.
I tried with the following codes in viewDidLoad method of the table view controller. But they are not working..
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
self.tableView.backgroundView = nil;
Is it possible to show the cells with a dimmed background?
Thanks in Advance
I use: (in viewDidLoad)
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.opaque = NO;
Then in cellForRowAtIndexPath:
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithWhite:1 alpha:.55];
Not sure if this is what you wanted, but it gives you the option to make everything clear. (obviously the alpha would change for your case, but that measures theo pacity of the cells)
Just altering the tableView doesn't help. You have to mess with the cells also. Inside the cellForRowAtIndexPath:(NSIndexPath *)indexPath method, put this before the return statement:
UIView * bgView =[[UIView alloc] initWithFrame:CGRectZero] autorelease];
bgView.backgroundColor = [UIColor clearColor];
cell.backgroundView = bgView;
How can I make the background of the accessory clear? I've managed to set the rest of the elements to [UIColor clearcolor] but it doesn't work for the accessory...
Here's what my progress looks like:
[self.accessoryView setOpaque: NO];
self.accessoryView.backgroundColor = [UIColor clearColor];
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"Icon.png"]];
self.accessoryView.backgroundColor = [UIColor clearColor];
Thanks for any help you guys can offer!
have you tried
cell.accessoryView.backgroundColor = [UIColor clearColor];
I want to have a background image behind my UITableView. This works fine, but for each grouped UITableView it seems to be using my background image. I just want it to use the background image once:
Note: This is all inside of a UITableViewController class
self.view.backgroundColor = [[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"background.png"]]autorelease];
self.tableView.opaque = NO;
self.tableView.backgroundView = nil;
headerView.backgroundColor = [UIColor clearColor];
footerView.backgroundColor = [UIColor clearColor];
You need to do two things:
Set background view (color) not in the UITableViewController, but in his parent (UINavigationController most likely, right?)
self.parentViewController.view.backgroundColor = [UIColor redColor]; // or whatever your image is
Set clear color for tableView background color (and optionally for its separatorColor)
self.tableView.separatorColor = [UIColor clearColor];
self.tableView.backgroundColor = [UIColor clearColor];