I want to get rid of this white border or colorize it to black.
As you see on the image, i want to change the white borders those shown in red circles.
How can i change it?
after adding this cote to tableview controller's viewDidLoad method;
[self.tuzukCell.contentView.layer setBorderColor:[UIColor blackColor].CGColor];
[self.tuzukCell.contentView.layer setBorderWidth:2.0f];
the resulting border is:
for static cell.. all of these methods .. must be setup in the storyboard file..
so..
click on storyboard file / Table view / Separator "none" / and choose desired color..
UITableViewCell contentView's underlying CALayer
Firstly import QuartzCore
#import <QuartzCore/QuartzCore.h>
Add this in cellForRowAtIndexPath in UITableView delegate method
[cell.contentView.layer setBorderColor:[UIColor blackColor].CGColor]; //any color u want to....
[cell.contentView.layer setBorderWidth:2.0f]; //set its width here
EDIT :Use this property according to requirement if tableview is static:
separatorStyle property
separatorColor property
backgroundView property
In CellForRowAtIndexPath, try this (after you init your cell) :
cell.layer.borderColor = [UIColor blackColor].CGColor;
Of course you can change blackColor to any other UIColor.
You can also do :
cell.layer.borderWidth = 0;
If you just wan to hide it.
the following code will change the separator color, which means that it will change the separator line between the cell and the border itself.
try this to change it to black:
tableView.separatorColor = [UIColor blackColor];
or to remove it:
tableView.separatorColor = [UIColor clearColor];
Related
I have a grouped table view on one of my view. And inside the cellForRowAtIndexPath delegator method I have set background color for each table cell as follows.
UIColor *color = [UIColor colorWithRed:221.0/255 green:241.0/255 blue:249.0/255 alpha:1.0];
[cell.contentView setBackgroundColor:color];
Background color set without any problem. But problem occur in top and bottom cells. In top and bottom cells have curved edges. But when I add the background color it distort the edges. I have uploaded a print screen in such window.You can see the issue occure in the bottom cell where i have set the background color. Can some one please tell me how to solve this problem.
Use cell.backgroundColor = [UIColor redColor];
not
[cell.contentView setBackgroundColor:color];
A UITableViewCell is a more complex object than an object with a contentView propretry.
You can find more about cell in UITableViewCell Class Reference
Set the cell's clipsToBounds property to YES, that should make it respect rounded cell boundaries.
I use a grouped tableview and custom cells which I load from nib. When I set the background colour of tableview to clearcolor then I can only see the contents of the cells but nothing about the tableview. I like the rounded corners and seperator lines of the gropued view, so I want to keep those lines and change the colours of the lines, but set the table's background colour transparent so I will see the main image of the window. is this possible?
So you wanted to change the color of separator lines
self.tableView.separatorColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
// give your hex color code or your color
Inside of viewDidLoad of your view controller you need to set the backgroundView to nil and the backgroundColor to clear.
self.tableview.backgroundView = nil;
self.tableview.backgroundColor = [UIColor clearColor];
I want to change the color of UITableViewCellAccessoryCheckmark and UITextField background color where we type. I found this is not straight forward.
I solved this issue by changing the tint color of the UITableView where the cell belongs.
Update the Tint Color of UITableView in interface builder to Default
or programmatically as below.
For Objective C
yourTableView.tintColor = [UIColor blackColor];
For Swift
yourTableView.tintColor = .black
By default,you cannot change the color of UITableViewCellAccessoryCheckmark
But alternatively you can use the image for this..as just like checkmark
while for textField you can use this single line..
[textField setBackgroundColor:[UIColor redColor]];
How do I fill the background color of a UITableViewCell? I tried this code but it didn't work.
cell.backgroundColor = [UIColor redColor];
Try setting a backgroundView for UITableViewCell :
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor redColor];
cell.backgroundView = bgView;
// release object
[bgView release];
You can change the selection background view of UITableViewCell the same way.
cell.selectedBackgroundView = bgView;
Setting the background color though UITableViewCell's backgroundColor property only works in a Grouped table view. So if your table view is in the Plain style then it won't work.
You can of course set the background color of the UITableView's contentView. But then you probably have to do some additional work as the other subview (text labels and accessory views) have their own idea of background colors.
Take a look at the following snippet from the UITableViewCell documentation.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html
Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.
That should solve your problem.
I have subclassed the UITableView control, and the style is grouped, but I do not need the cell separators. I tried setting my table view's separatorStyle to none, but it doesn't work. Can any one help me out?
In a grouped table view, setting separatorStyle doesn't do anything. If you want to hide it, just do the following:
tableView.separatorColor = [UIColor clearColor];
Use this
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
To remove the border of a table view write this line:
self.myTableView.separatorColor = [UIColor clearColor];
If you want to remove both the border of a table view but the border between cells too, you have to write both lines:
self.myTableView.separatorColor = [UIColor clearColor];
self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
This did the trick for me:
[dayTableView setSeparatorColor:[UIColor whiteColor]]; //or your background color
swift 4 use
myTableView.separatorStyle = UITableViewCellSeparatorStyle.none
How about setSeparatorColor to your cell's background color?