What are these UITableView lines in the image? - uitableview

I have a UITableView on a UIView. This UIView is in a UICollectionViewCell which means that I can do the action you can see in the image. A new UICollectionViewCell is coming on from the right. As a new cell comes onto the visible rect it is slightly resized you can see that the right one is slightly smaller.
While this new cell is "sliding on" the table view has some black lines that show through. It is not the actual separator lines as you can clearly see them, further turning them off or making them the same colour as the cell does not change things.
So can anyone tell me what these black lines are and if I can either directly get rid of them or cover them over somehow.

I believe that the lines are cell separators. You could set the separatorStyle property to UITableViewCellSeparatorStyleNone.
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

Related

Trying to hide UITableViewCell separator by using insets but it only decreases in opacity

I am trying to hide a UITableViewCell's separator by pushing it all the way to the right as far as it goes. So I set both the cell's separator inset and layout margins all the way to the right as far as they go. But this only makes the cell slightly more transparent. As you see in the picture, the lower line is slightly more transparent than the one above. There seems to be another line for the cell below the one I hide that I can't remove for some reason. No idea what could be causing this.
You can hide the separators by calling table.separatorStyle = .None on your UITableView.
Edit 2: I couldn't tell by the question that the goal was to remove cell separators for just one type of cell: as mentioned in my comment below, I'd advise removing the separators with the line above and adding a small-height UIView as a custom separator where you want it.
Hide tableview seperator simply by setting its property in attribute inspector.
Simply select the Attributes inspector and set seperator = none if you want to hide then otherwise if you want to do any operation with seperator color then set color on there.
UITabieViewCell generally contain two subviews: content view and separator line. If a cell's height is 44.f, content view's height is 43.f and 1.f for the line. You just move the line away, but the height of it is still there.

ios tableView clearColor seperator

I have set my tableView's background color, and I want there is space(10px) around each cell show that color.
e.g.(ignore the red line)
What I am doing now is make the cell embed a smaller view, and set the cell's background to be clear. But it is annoying to create such embed view again and again.
So, I am seeking for a better solution, I believe it would be good if i can increase separator's height. But the old answers did not solve my problem.
(How to increase the UITableView separator height?)
EDIT:
However, if I add my own separator in cell. I may not able to set the cell having round corner
Set the tableView's separatorStyle to .None.
Create a custom UITableViewCell subclass.
In the storyboard (or xib if you created one for the custom cell), add a subview that's inset the amount that you want padded on all four sides.
If you want rounded views, do that on the custom cell's subview (e.g. subview.layer.cornerRadius = 10.0, subview.layer.masksToBounds = true).
Set the custom cell's ContentView to have a clear background.
Set the table view's background to that lovely shade of blue.
Set the cell subview's background color to white.
You don't have to use the cell repeatedly in InterfaceBuilder. Just give the cell an ID, and in your implementation of the table view's data source, dequeue a cell instance using that ID and set the values of the labels inside it.
Have you thought of just making the cell height taller and putting your own separator on the bottom of your custom cells? Nice table layout by the way.

iOS: UIView backgroundColor in table view

So this problem is pretty weird and a little difficult to describe. Essentially I have a UITableView where each cell has an image, and a UIView covering part of the image. The UIView has it's background colour set to about 30% transparent white, giving it the appearance of washing out the image beneath. There's also some labels and such on it. All these views are added to a single parent container view, which is finally added to the cell's contentView. This all works fine - until I try to select the cell. For some reason, whenever the cell is highlighted, the backgroundColor property on each and every one of those views is set to clear, until the cell is unhighlighted (at which point the old colour returns).
Can anyone explain why this happens, and more important if there's a way to fix it? At most I could create a single pixel image of white, turn the UIView into a UIImageView, and set it's image to that pixel - but that's inelegant at best. Any suggestions?
When you select the cell, the implementation of setSelected:animated: is called and set the background color of all the views included in this cell to transparent.
Simply, you can just disable the selection of the cell by setting its selectionStyle to None:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Or, if you want to use the result of selection, you can override the setSelected:animated: method and reset the background color of your UIView

UILabel in UITableViewCell Getting Drawn Over Accidentally

I'm using a prototype cell inside a grouped UITableView to create custom cells with two UILabels inside. Each UILabel is populated with text. The first UILabel, alligned on the left of the cell, behaves appropriately.
However, the second UILabel, which is toward the middle of the cell, is somehow being drawn behind the cell's background! I can't explain why, but if I set the background color of the cell to be clearColor instead of the default, the 2nd Label can be seen and works just fine. It also shows up if I highlight the cell, but disappears again when unhighlighted. I am sure that the label isn't just "blending in" with the background; the background is white and the label is black.
Any ideas? I'm a bit stumped. Is there some sort of issue with prototype cells and having more than one label?
Edit: Answered my own question, see below.
Okay, this has been resolved!
So like I said, I was setting up prototype cells in interface builder with two UILabels. To access these UILabels in my cellForRowAtIndexPath delegate method for my UITableView, I was using the Label's Tags. The first label I had tagged as "1", and the second label tagged as "3" (don't ask why it is 3 and not 2). Anyway though, it turns out that UITableViewCells already have a label with special properties setup with tag 1. Besides the label with tag 1 hiding my 2nd label, it was also remaining centered in the cell when I was changing cell size dynamically (when I wanted it to stay at the top).
Long story short: UITableViewCells have a "special" label already built in with tag of 1, so I changed my first label's tag to 10 and everything went back to behaving as I would expect.

Kind of complicated custom UITableViewCell

I have a particular goal in mind here, searching for it is a little hard. I am trying to accomplish this (This is a photoshopped screenshot):
I have everything in this view working, except for the split row for the Company Name/ Beginning of the field row. The "Company Name" field is just a textfield, all I really want to do is shrink that neato cell background to just go behind the right side.
Create a custom table view cell that has two subviews: the text field on the left and a UITableViewCell on the right as a subview of the main table view cell. A UITableViewCell is just a UIView so you can actually add it as a subview of any view. The main table view cell will have it's background color set to transparent.
So totally complicated custom cell comes with a totally ridiculous solution. I built a view for the cell that has the one field...and another UITableView.
That second UITableView has the "Beginning of the field" text, and its cell gets the background, and I hide the background of the main cell.
I had to play around with the nested table's size and position to get the row to display properly, and make sure that the lines in the background don't shift when it hits the nested table, but it came out perfect
You could try setting the frame property of your cells backgroundView to cover only have your cell's width. Address Book handles complex forms like this with a nice look and feel--you might want to see what they've done there..
One approach would be to define a custom table view cell, set its background transparent and add the UITextField on the left and a UIButton on the right (customize it to look like your other cells), as in your screenshot.

Resources