On the app Foodspotting, you have a scrolling view that has two elements:
1) An image.
2) Some information below it.
Like this:
When you start scrolling down, the behaviour is not natural of a UITableView, or at least I am not understanding it. The below view start's going up and overlapping the UIImageView above it:
And finally:
What I have tried:
1) Using the first four cells without content and invisible and finally an UIImageView as subView of the UITableView
2) The same as above but using the UIImageView as subView of the root view and below the UITableView.
3) Mixing the UITableView and a UIScrollView with an UIImageView inside the UIScrollView.
So my question, how was this achieved?
Edit 1.0
If someone want to try, you can check the project here.
Looks to me like a UIViewController with a UIImageView on the bottom.
Then a UITableView on top of that (grouped table view) with a transparent background.
The header height is then set to almost the height of the entire view. With a button (or whatever that is) near the bottom of the header.
You could access the scrollView:didScroll to adjust the position of the UIImageView in the background (it looks like the center point of the image is always half way down the visible part of the header.
bgImageView.center = CGPointMake(0, (bgImageView.frame.size.height - scrollView.offset.y) * 0.5);
or something like that.
Obviously the image view would not move any further down than the top so you'd have to catch that somehow.
Looks like an image view is the background view of the table (so it won't scroll), a large transparent view as the table header (possibly with that first button in it, or that could be a transparent cell) then opaque cells for the remaining content.
And that risotto is far too wet. 0 stars, more like rice soup.
Related
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 have a horizontal-scrolling UICollectionView which is nested in a UIView that is centred and occupies 80% of the screen width.
I want the UICollectionView to be visible screen edge-to-edge rather than constrained to the super UIView bounds.
I have set the following which shows the UICollectionView across the screen width:
collectionView.clipToBounds = NO
...but when dragging the collectionView, it hides cells when they are completely outside of the super UIView bounds even though they are partially visible on the screen, which leads to a weird flickering of blank space/cell.
Ideally, I'd like a way to prevent the hiding of the cells completely out of bounds. Is there a way to do this?
The UICollectionView has a maximum size of 3 cells, so I'm not particularly worried about any performance implications of having all cells visible all the time.
The only way I found is to enlarge the frame of the collection view (and its superview in your case) and add contentInset's to it. You might also want to update scrollIndicatorInsets.
I am trying to recreate a UIView I have seen in multiple apps, mainly Shazam. The top half of the screen has some interactive buttons, and the bottom half looks like a tableView with custom cells. When the bottom half is panned/swiped up, the tableView scrolls over the top half with velocity, much like a scroll view.
I have been researching this and experimenting for a couple days now. I have gotten close, but not quite there.
My last approach was a view that had a tableView inside it. When the view was panned, the view would move to wherever the finger moved it to, but then would not have any velocity afterwards. Also when the tableView was panned/swiped down, it wouldn't move the whole view down.
Before that I tried a scrollView that took up the whole length of the screen. That gave the desired effect, but the button wasn’t tappable, and you could scroll the view in the button area, which is undesired.
Does it utilize ScrollViews or is it using a tableView that acts much like a ScrollView somehow.
Here is the Shazam UI/UX I am looking to recreate:
The top portion has interactive buttons, and doesn’t scroll. The bottom half shows content and when scrolled, covers up the top portion.
Below is what I have tried so far: This one is the panning view, which sort of works, but doesn’t have velocity and the tableView doesn’t scroll the view back down.
Any thoughts on a direction I can take from here is greatly appreciated. I am using Swift.
Cheers
This sort of thing is perhaps best done with a collection view and a custom layout — you can have some items for which you set layout attributes absolute to the view, and others relative to the scroll content offset.
There's a great (if wandering) discussion of this and other techniques in the Advanced User Interfaces with Collection Views talk from WWDC 2014.
This is actually simple than it seems at first. Here's how you can achieve this:
Create a UIViewController (not a UITableViewController).
Add some buttons to the top area of the screen.
Add a table view spanning the entire view controller's view. Make sure the table view is on top of the buttons added in the previous step.
Configure the top cell of the table view to be transparent (by setting its background color to Clear). Set the background color on the table view to Clear as well. This way it won't obscure the elements at the top of the screen, unless the table is scrolled up.
Because your table view is now transparent, you'll need to explicitly set the background color on the table cells other than the top one.
Profit!
I have UITableView with background image and then I scroll it I have parallax effect like background imageView scrolls too. Problem is that then my image finished I have tableView background. Is it possible to make infinity imageView? Like then I go through image then starts this one image from beginning.
In next few days I will add lib thay solved it and creates parallax effect under tableView
https://github.com/bizibizi/TableView-Parallax-Background
Can you show me how are you placing that image behind the TableView? I guess the hierarchy in the storyboard should be
UIView -> UIImageView -> UITableView
The size of the UIImageView and the UITableView should be the same. So when you scroll up and down the UITableViewyou could see the image in the background.
But please explain your scenario abit more so that I could suggest you something appropriate.
What Hanny means is that you need to have the tableView on top of imageView ordered in the stack of the parent view's subviews. What you can also do is stack two tableviews on top of each other, and add a touch event that moves both table view's scroll views. The image table view would contain cells that are the size of the whole view frame.
I have a view in which I have UITableView (grouped style). In the Interface builder, I am resizing the UITableView so that it looks like a small portion in center of the screen.
But when I run the application, UITableView takes up the whole area of screen and does not look like the small portion in center of screen (which I had set in Interface builder).
I tried to resize the tableView programmatically in the viewDidLoad method as tableView.frame = CGRectMake (0.0,0.0,100.0,100.0), but still the tableView occupies the whole area of screen.
Please help.
Regards,
Pratik
Sounds like your table view's got autoresized. Try to fiddle with the autoresizing settings.
If your table view is the main view then it will automatically fill the whole view controller's space regardless of the autoresizing settings. In that case, make an empty UIView as the root view and put the UITableView as a subview of it.