Tableview gets black while data loads from the server - ios

hello I have tableview in which I am populating data from the web service. I am showing activity indicator first on the tableview until data comes from the server. The problem is while spinner is moving table gets black until data comes up and table moves to white color like I designed. But Before that it shows separator lines and black background for like 2 sec. How can I show complete white background with the spinner and also with no separator lines like in many apps.

The black background is most likely the background color of your tableView, because before populating the tableView your reusable cells don't exist in the view. If your tableView has a transparent background the black color is due to the color of the background of your view.
If you want to get rid of the separators just for the loading, I suggest creating a tableFooterView and removing it when populating the tableView.

Not sure what causes the black color from your comment but you can disable separator lines as such:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone

Related

How do I put a black opaque background behind a UI tableview?

I have a textfield that, when text is entered, pops up into a tableview. The tableview only takes up the bottom half of the screen, and when the tableview is showing at least one option, I would like to make the rest of the screen an opaque black. (Note, I’m not talking about the color of the tableview itself, but adding a dark tint to the rest of the screen.) The area on top of the tableview also has other elements, so it’s not as simple as just changing the background color. Whenever I try to change it from where the tableview is controlled, I end up just changing the background of the tableview itself.
Here is a visual of something similar to what I’m trying to achieve:
https://images.app.goo.gl/npAE5ga2kCmQ8E2d7 .
Any help would be greatly appreciated!
1) Add your Selection options in new viewController names as optionPopUp(what ever you want).
2) set modalpresntationstyle of your new popUp as over current context with transition style as crossdisolve.
3) set background view color of new popUp viewcontroller with opacity(0.1 or 10%).
**4)**Present you popUp from source view controller i.e in didselectrowat method of uitableview delegate

Swift - Empty space when dragging down CollectionView Header

I'm currently building a collection view with a header, I've got all the pieces working, so I don't necessarily have a question/problem about code, header works fine and so do the cells. My question is about the header and when you drag it down, you can see the background color. Currently, I have my header's color set to Gray, and the background color of the controller is set to white, so when I drag the header down, I can see the white background.
My question is.. what code do I need to implement in order for the gray header to be continuously stuck to the top even as I drag the header down?
I'd like to figure how to implement this because I want to keep the spacing of my collection view cells white and not gray (If I were to change the background color to gray).

How do I make tableview cells completely opaque, when overlaying them on top of a background?

I have a search bar that displays results in a tableview. The search bar is always visible. However, I hide the tableview by default, until the user starts typing within the search bar. Therefore, the tableview cells are only visible when the search bar is actively used.
The reason I do this is that I'm displaying various labels and text in the background.
I've tried hiding and unhiding the labels and text in the background when the search bar is activated, and subsequently de-activated. This works. However, is there a more elegant way?
// TableView is hidden by default in viewDidLoad()
SearchBarTableView.isHidden = true
// TableView is also hidden when searchBarCancelButtonClicked
SearchBarTableView.isHidden = true
// TableView is turned on within the searchBar function
SearchBarTableView.isHidden = false
The problem with the existing code is that the tableviewcells have a transparent background, where the searchbar results overlay on top of my other labels and text in the background.
I'd like the tableviewcells to have a solid background, that erases everything under it.

TableView Cell background on edit not working

I have a tableview with a transparent background, and a content offset to allow part of a background image to be visible at the top of the first cell. The content offset is set with: accordianTableView.contentInset = UIEdgeInsetsMake(100, 0, 0, 0)
As shown in the following image, the green highlighted rectangle is the first cell of the tableview, which has a solid white background. The cell is in edit mode, but there is a transparent section when the cell is dragged to the right, where the background image is visible through the cell even though it has a white background...
I cannot have the background of the table view solid white, since this would cause the background image to be totally invisible through the table view.
How can I make the entire cell background always white, even when dragged to the right while editing?
Worked around the issue by adding an empty UIView behind the tableview, and changing its position to always be behind the tableview - providing a background color for the cells while in edit mode.

UITableView cell borders bleed through

I have two groups of cells, we'll call them header cells and body cells. I will always have 4 or less header cells, and 1 or more body cells. The header cells have a colored background (all the same background) and the body cells are all white. The problem is that when I scroll the tableView background color "bleeds through" between cells. This is not a cell divider. The image I attached shows what happens when I set the color to the green that's in the header.
I tried using clearColor for the background, but that shows a black line between all cells, which is not good. So far, we've just given the tableView a white background, since the majority of the cells are white it would be less noticible.
I also tried setting the tableView background color in the cellForRow, depending on the section, but that just causes it to switch what color is popping up, as I thought it would.
How can I get rid of the line that come through when scrolling when the cell background color is different than the tableView background color?

Resources