I have a custom UICollectionViewCell, I have few views in its contentView.
I have an UIImageView with image (1 pixel colored) and I use it to fill my view.
I also cut the corners like this -
self.myBackground.layer.cornerRadius = 8.0;
self.myBackground.layer.masksToBounds = YES;
Color of my view and all collectionViewCells and their contentViews is [UIColor whiteColor]
But I am getting weird grey line below it. I am not setting it anywhere and I don't need it.
How can I remove it?
I have found the answer, it is separator. After setting separator view to nil it disappeared.
Related
I have a UITableView with 10 cells.
I've changed my UITableView's background color to red, but now there is a small red line between each cell (in addition to the separator line).
I need to disable this small gap between the cells that the background color won't be visible between the cells.
Screenshot:
Does anybody know how can I do this?
Thanks!
By going through your snap shot it is clear to me :
there is a separator which is a thin black line with custom offset set. That you can removed as mentioned in one of the answers.
other one is there is a red colour appearing in between cells. Please check is your tableView cell has clearcolor set. As you can see the last cell doesn't have red coloured line in bottom. Which i feel is you have a label over your cell which starts some pixel below the actual cell starts and hence you are able to see red coloured line over all cell excepts bottom of last cell.
In storyBoard select your tableView and then select "Attribute inspector"(at Right side) then Set "Seperator"->"None"
You can also do it by programatically -
UITableView property separatorStyle. Make sure the property is set to UITableViewCellSeparatorStyleNone and you're set.
example -
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
Try this in viewdidload:
self.tableview.backgroundcolor =[UIColor clearColor];
or
self.tableview.backgroundcolor =[UIColor whitecolor];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
I've got an UITableView with clear background color. The cells are made of:
bckgrndView - slightly bigger to get spacing betweens cells
-> contentView - contains content, set green
-> -> label, textview - green too
I set everything in interface builder (backgroundColor -> clear, opaque -> no), expect that i have to repeat
cell.backgroundColor = [UIColor clearColor];
cell.opaque = NO;
cell.backgroundView = nil;
in cellForRowAtIndexPath or else, background would be white (bug?)
But as soon as i scroll the clear color is gone and the spacing gets green(== same color as textview)
What am I missing?
Fixed it!
Renaming the inner view differently from "contentView" did it.
UITableView has a own property named "contentView", so there was the conflict...
I have a problem of the implementation of UITableViewCell's separator.
As you can see from the screenshot, there is a white gap visible before the separator, I think that is because I set the bg colour of the cell as light grey and also I put the inset of the separator as 53.
My first attempt was instead of using the separator, I was trying to draw the lines at the end of the cell by my self. But since on selection of the row the content of the row get updated, and there is a lot of issue regarding the calculation of the height of the cell.
So basically it is really hard for me to draw the line pixel precise at the end of the cell.
This left me the option to access the cell's separator's view, which currently not aware of any easy way, and fill the gap with my default background colour of the table.
My question is, how can I access the separator view
Or
Do I have any other alternatives to implement what I want?
Thank you very much.
UITableView doesn't provide APIs to access or modify the cells separator view directly. However, it has methods to change it's color, style, etc. Most of the times, though, the only solution for a custom separator is to draw it yourself, or better, to set the cell's backgroundView property to a simple view with a line subview or layer in it (a subview, although has some overhead, gives you the flexibility of autoresizing automatically using autoresizing masks or auto layout).
e.g.
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.bounds];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(backgroundView.bounds) - 1, CGRectGetWidth(backgroundView.bounds), 1.0f];
[lineView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin)];
[backgroundView addSubview:lineView];
cell.backgroundView = backgroundView;
Use this workaround:
Put UIImageView at bottom edge of cell and you can set image as per your requirement
STEP 1: Set divider as per image
STEP 2: Set Separator style to none
Since iOS 7 you can use this
cell.separatorInset = UIEdgeInsetsZero;
Is possible to create this separator style effect programmatically?
I have tried adding a uiview with an image created with photoshop but doesn't work very well.
Thank you
I would simply set separatorStyle = UITableViewCellSeparatorStyleNone and in the cell view add a UIImageView subview that has the separator you want at the bottom.
You can use a combination of separatorStyle and separatorColor on the table view. You can also add views with images or simply background colours and transparency to the top / bottom of your cells.
It looks like you could just set the tableView.separatorColor = [UIColor blackColor]; and add a 1px high view to the top of your cell with a white background and alpha = 0.1.
You can achieve this by setting a background image to your view and make tablecell seperator color [UIColor clearColor]
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
tableView.separatorColor = [UIColor colorWithRed:132.0f/255.0f green:132.0f/255.0f blue:131.0f/255.0f alpha:1.0f];
I want to display a double bordered like following image...
The border has a dark color (magenta) and a light color (white) (not the actual colors).
I have created a custom .xib file and a custom class extending UITableViewCell for my table view cells.
self.tableView.separatorColor = [UIColor whiteColor];
Then in the custom table view class, I did this...
- (void)awakeFromNib
{
[super awakeFromNib];
UIView *cellBottom = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height, self.bounds.size.width, 1.0f)];
cellBottom.backgroundColor = [UIColor magentaColor]; //
[self addSubview:cellBottomView];
// ... other code
}
I got the following result... there seems to be some gap between backgroundColor and separatorColor.
Why is this happening? The height of UIView has been set to 1 and is positioned at the bottom of UIView as well.
If there is some better solution to this could somebody throw some light on that?
Michal Zygar is partially correct.
Make sure your -(NSInteger)tableView:(UITableView*) heightForRowAtIndexPath:(NSIndexPath*) is correctly set to the height of the view. It doesn't automatically do that for you.
The other tip I would suggest as I do it myself, is to NOT use separators. Set your separator to none, and then add in two 1px-heigh views at the top and bottom of the cell in the XIB file.
Make sure to set the autosizing for the bottom two to stick only to the bottom edge, just in case you want to change the cell's height!