问题
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:
回答1:
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..
回答2:
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
回答3:
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.
回答4:
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];
来源:https://stackoverflow.com/questions/13413358/how-can-i-change-ios-table-group-border