I was wondering want the best way to add drop shadows to a set of collectionviewcells that do not have spaces between them?
Background
Part of my layout has various cells positioned across the screen like a post. It notes and the second half of the layout is structured to look like a tableview except all the cells don't go to the edges there's a bit of padding. So I can't really add a shadow around the collection view itself.
I have added shadows to the cells in the post. It note part which works great because the cells have spaces between them but I'm now struggling with the second half (the tableview looking part) because obviously when you add the shadows to the cells depending on the zIndex you may see the shadow overlapping the below or top cell.
So I was wondering what is the best way to do this?
Should the shadows decoration views underneath the cells?
OR
Should the shadows be attached to the cell and increase the ZIndex for each cell so they appear on different levels hiding the shadow - but that leads to a question on how to do the first cell and have a top shadow?
OR
Should I almost fake it by using an image of a shadow inside the cell itself?
I also have deletion functionality so I need to figure out how to make sure if I delete the first cell, the second cell should then have the top shadow in a nice animated way.
EDIT:
I am trying to create the following view inside the collection view. I have got the layout correct. 1
The green lines are the shadows I have working but the red are the ones I'm having trouble with and the boxes are the different cells.
Related
There is a collection view cell and a view of the same size right under it.
Instead of separately adding two circle borders for both the cell and the view, I want to add one for them together (forming a rounded rectangle)
Is this possible?
If yes, how to handle the scrolling of the collection view?
Yes it is possible but tricky.
I'd suggest you really try to combine it into one cell to avoid lots of headaches.
If you can not then you need to toy with the collection view layout to get your cell to line up correctly with the view underneath and you need to figure out the scrolling as you indicate.
I've sometimes had to use two consecutive collection view cells that needed to align and it was terrible to get it right, thus I suggest try to solve this problem using just a single cell. FWIW the last cell in a collection view often shifts slightly compared to the others so I've sometimes added a blank cell last just so my second to last will align correctly.
Is it possible to reduce the padding surrounding each table view cell in a table view? I understand I could do this through a custom solution but I would like to have the default auto-resizing behavior of a standard table view cells but just reduce the padding between cells.
I'm not sure if I completely understand your question, but when working with table view cells, I generally
Get rid of the line operator
Set the background color of the cell and the table view to be the same
Create a subview that is essential all the design of the cell
By doing this I can make the subview a different color and increase or decrease its size, and in a way, it acts as padding between cells.
Again I'm not totally sure if that helped, but if it and you would like the code for that just respond to my answer.
Hi I am trying to achieve this:
Every search gives me a horizontal list that is contained inside the card and every image disappears into the cards border. Any tips on how to achieve this effect?
First of all, I'm not sure if your question is a programming question, but I'm answering your question anyway.
So you could have UICollectionView and each item (row) has another UICollectionView.
Since I prefer UITableView most of the time, I would use UITableView and each row (each UITableViewCell) has a UICollectionView for displaying the horizontal scrolling albums.
The white container in each cells/rows is merely a UIView with constant height and dynamic width (leading and trailing are clipped to the superView with inset, say 10.0). Then the UICollectionView is clipped to the superView (UITableViewCell) with no offset or zero offset/inset.
If for adding shadows to your view with rounded corners, there are multiple ways to achieve that, but I'm giving you a quick link for your reference: https://medium.com/swifty-tim/views-with-rounded-corners-and-shadows-c3adc0085182
I hope this helps!
Put three collection views that that stretch between the card borders. Let the collection views have a transparent background.
Then place the three smaller white views behind the collection views. Give these views a drop shadow.
I am trying to implement something like this:
I have a UITableView with 1. "static" section, the total number of sections in the tableView can vary. I always want the first section (white area) to be visible to the user, the remaining sections should scroll underneath the first section. I have tried to implement this with two UITableViews, but since the (white area) can vary in size, I can't set a definite frame. I am using Storyboards with autolayout. At the moment the best solution I have come up with is the two UITableViews, but I need to find a way that I can resize the two tableViews according to the content of the white area and according to each other. The white area, one of the tableViews is containing a section with two rows, the first row is containing text that can vary in length and therefore needs dynamic resizing.
Any Idea how I can tackle this? Can I change the NSLayoutConstraints dynamically somehow?
If i understand correct, your first UIView rectangle if fixed, bottom table is scrollable.
To implement this, you should create typical UIViewController, add UIView and UITableView (programmatically or through an outlets). You should manage each view (tableView and UIView) separately.
I'm trying to create a simple effect where a cell casts a shadow on top of the cell directly below (in a vertical UITableView). Much like a tiled roof where the top tile is layered above the tile below and casts a shadow on the cell below.
I've tried overriding layoutSubviews in UITableView and played with bringSubviewToFront etc but that did not work. The shadow works somewhat but disappears as you tap on a cell (somehow the selected view overlaps it).
Any way to do this easily?
It seems the only reliable way is to draw the 'shadow' on the cell below the top one and then keep track of global selection states. A second option is to use UICollectionView instead but that's an overkill.
For cell dropping shadow on the one below:
Add shadow to the layer of a view in your cell.
For all cells dropping shadows only on the background view
Add shadow to the layer of the tableview itself.