I've put a UITableView into a UIVisualEffectView to achieve vibrancy. Everything works fine except for the bounce feature. The space where no cells are while scrolling gets drawn in some grey color instead of the blurred effect. I have tried to set all the background colours to clear but the blur still won't show. Is there any way to give the background the same effect as the rest of the table view?
You can find the demo project here
set Clear color of Table view, TableviewCell and ContainerView from Property. if not Clear then put code in your view Controller. also selection of cell none option.
SWIFT
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.backgroundColor = UIColor.clearColor()
}
So I've found the answer. Instead of making the background a clear color, you need to set a white color.
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.backgroundColor = UIColor.whiteColor()
}
Related
I have a tableView in editing-Mode for reordering Cells. I want to customize the color of the Knob for dragging the Cell. Actually, it is light grey. To understand what the picture is showing: I have a Cell with a height of 70, and a uiview with a height of 60 in it because I want more Space between the Cells. That's why you see the grey parts of the knob (yellow arrows). These I want to have in the same Background color as the tableView itself.
Maybe someone knows how I achieve this?
So far, I've no hint to how set its background color. However there is others options you want to explore to have this space between cells :
Add extra "empty" cells between cells
Add sections for each cells.
I'd go with the second option if I could afford it.
PS : Maybe you can a view under your tableview with the desired color.
Ok... Got it. Using the Code from here Change Reorder Control's color in table view cell i modified it in this way:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
for subViewA in cell.subviews {
if (subViewA.classForCoder.description() == "UITableViewCellReorderControl") {
subViewA.backgroundColor = UIColor(red:0.89, green:0.00, blue:0.45, alpha:1.0)
break;
}
}
}
Now it looks like i want:
Nice looking
Using Xcode 10+, Swift 4+, iOS 11+
I've created a simple Search View that has a SearchBar at the top,
with a UITableView beneath.
When the view is first displayed, the Table is empty, and as the user enters text into the search bar, I add results to the table. Functionally, everything works ok.
Next, I've made the main View background blue and want the entire TableView to be clear so I can see the background.
I've set the table view background in the "viewDidLoad" :
myTable.backgroundColor = UIColor.clear
In "cellForRowAt" I set the cell background to clear:
var cell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: "cell")
cell.backgroundColor = UIColor.clear
cell.contentView.backgroundColor = UIColor.clear
However, when the search returns values and cells are added to the table,
they always have a white background instead of clear.
If I pop and then push the Search View without clearing the table, the existing table cells show up (redraw) the way I want them - clear.
I've also tried adding this to "didFinishLaunchingWithOptions" but it does not help:
UITableViewCell.appearance().backgroundColor = UIColor.clear
How can I make the cells show clear when they are first created?
try to set cell or tableView backgroundColor when cell will dispaly.
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.backgroundColor = UIColor.clear
}
or you can override function setBackgroundView to debug problem.
I'm implementing drag and drop between two UITableView's.
When dragging an item over tableView, the tableView automatically displays the space where the new cell will be inserted. I'd like to highlight that space by changing the background color.
Currently, the space for the new cell shows in white. If I change the background color of UITableView, then the space reflects the corresponding background color. However, I do not want to change the background color for the tableView.
Can someone help on how I can achieve it?
Here's a screenshot of the functionality that I'm looking for.
Thanks,
Felix.J
Depending on if you're trying to set the background of the future location of the cell or the cell itself, you can alter the background and add effects to the drag cell by calling the dragPreviewParametersForRowAt function. For example:
func tableView(_ tableView: UITableView, dragPreviewParametersForRowAt indexPath: IndexPath) -> UIDragPreviewParameters? {
let param = UIDragPreviewParameters()
param.backgroundColor = .clear
return param
}
would remove the default white backdrop while a cell is being dragged within a table view.
I have a storyboard consisting of a background image on top of which rests a table. My issue is that the background image gets applied to the table but not to the cells of the table, they still remain white.
What is it that I am doing wrong?
Please help
You need to set background color as clear color of tableview cell as well as it's content view.
You should do clear back ground color of your cell by below delegate method.
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell,
forRowAt indexPath: IndexPath) {
cell.backgroundColor = UIColor.clear
}
in cellForRowAtIndexpath method, use
cell.backgroundColor = UIColor.clear
How to identify the exactly first separator? Or by Xcode. (how better to make a reference)
How to write it?
MyTableView setSeparatorColor:[UIColor NO COLOUR]
Trying to solve this programmatically!
separatorColor is the property of UITableView. Whatever value you assign to it last, it will override that value. So you won't be able to set different colors for different cells.
You can create your own UIView on each cell as separator with height = 1px and width as that of tableViewCell.
Hide the separator view for first cell or make the background color clear.
Assign any color you want for rest of the cells.
You can take help of willDisplayCell
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.row == 0 {
tableView.separatorColor = UIColor.clear
} else {
tableView.separatorColor = UIColor.green
}
}