Sticky bottom bar iOS with scrolling - ios

I was going through this Medium iOS app when I stumbled upon this amazing sticky bottom bar
See bottom bar. After the first content is finished and before the next content starts, the bottom bar starts moving
I tried it with using constraints and setting different priorities and their permutations and combinations but could not figure it out.
I also went through a library which does something like that.
Can someone explain me how to go about making this kind of bottom bar?

That can be done with the default behaviour of the UITableView Header/Footer depending on where you want the view.
Supply that view with its content to UITableView by it's delegate method viewForHeaderInSection or viewForFooterInSection and make sure your set the height correctly by the delegate methods heightForHeaderInSection and heightForFooterInSection.
That will give you a "bar" that moves in with it's content and out of view after it's related content is scrolled away.

Related

UITableView in ScrollView - how to change scroll handler?

I have a pretty weird setup due to time restrictions and UI requirements.
The layout is pretty simple: the root view is a ScrollView, with a StackView in it. StackView has two elements, a header (which I wish to collapse), and the content (which is a custom tab bar, and below that, a container view for the tab bar's linked content).
Latter is constrained in height to the ScrollView, resulting in a kind of "sticky header" (the tab bar's top sticks to the navigation bar's bottom) and "collapsing header" (the header view is "collapsed", as it is scrolled out of the view).
This works fine, however I can't seem to find any information regarding how to handle scroll events. What I want is a "single" scrollable view with the tab bar being sticky.
The end result would work like this:
User starts scrolling, ScrollView handles scrolling up until the moment it "bottoms out", then hands over scrolling to the UITableView currently visible. When the user starts scrolling up, the UITableView currently visible scrolls until it hits the top, and immediately hands over scrolling to the outer ScrollView, which will then scroll down the tab bar and reveal the header.
On Android it's quite simple to implement, due to the Toolbar component's extendibility, but on iOS I'm dead in the water how to implement this. I've tried looking up scroll handover, but haven't found anything related to my issue - possibly I've used the wrong search query, but not sure.
How could I hand over the scroll event the easiest way?

Create Shazam Type UI ios Swift

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!

UITableView not following constraints

I have in the bottom of the screen a view containing 4 image views that I use as navigation buttons. That view is pinned to bottom layer by "0". Now my tableview is above this view and I have made a constraint of "10" from tableview to my "navigation view." I have two problems. When my tableview contains more rows than the screen can hold it puts the cells "behind" my "navigation view" even though I made the constraint it shouldn't. Now when I flip the screen to landscape mode it actually makes my navigation view disappear from the screen. I don't understand why as I pinned the bottom view to bottom layer. (2 questions)
Then of course my 2nd row decides to use much bigger font when I load in more rows, which is something I don't even want to bother you guys with yet, I think my simulator is playing tricks with me..
Anyway, I appreciate any help on my 2 problems above. Thank you
EDIT: Here I took some pictures:
http://i.imgur.com/LA9Spt0.png (this shows what i mean with the tableview pushing away the lower view even though the lower view is constrained to the bottom layer and the tableview has a constrain leading to the lower view (menu bar))
http://i.imgur.com/b6VoqFk.png Here what happens when I "pull" the tableview downwards to see more cells it blocks the upper label and top bar (which contains the logo I had to remove for reasons with the company) I tried to use :setBounces and setAlwaysVertBounces set to NO but then I can't scroll down the tableview when more cells exist.
(addition to img. nr 2)multiple cells makes the cells hide behind the lower menu navigation bar. I did make a constrain between the tableview and lower menu bar, shouldn't I be able to make the tableview "create" a scroll bar so u can scroll down instead of cells hiding behind the menu bar.
Thanks, any help much appreciated!
It sounds like you have some conflicts, or missing constraints.
You can see if you have constraints errors in the nib, in the 'view hierarchy' column in the left side of your nib, you will see a little red arrow..
Or that you have some conflict which you can see at the console when running you app.
Thanks

How to create a layout like Featured page in App Store?

I'm new in iOS development. Based on my assumption, Feature page in App Store was created using a combination of UITableView and UICollectionView. But how to do that in theory and code? I know it's a bit vague, because it's quite hard to describe it, but I just need some people to help me explain it.
For this case I will try to use these naming:
1. Top section, it's a view which showing banners of apps, people can swipe it to view another banner.
2. Middle section, views which can be scrolled horizontally. (Best New Apps, Best New Games, etc).
3. Bottom section, starts from Quick Links to the bottom.
Questions:
1. The scroll indicator is starts from the root view's top guide, that's normal, but:
a. When we scroll it up, the bounciness is start from the middle section. How to do that? Is the top section and middle section is a separated view? But how can the scroll indicator is started from the root view's top guide if top and middle section is a separated view? (Separated view means that the views should have different scroll indicator unless it's actually subviews of UIScrollView).
b. When we scroll it down, there is nothing that floating. So it looks like that the whole page is a subview of a single scroll view but the bounciness is starts from the middle section. How to create that bounciness effect while only have one scroll indicator for the whole page?
2. In the middle section, there's a several collection view that has horizontal scroll direction. Is it the best way to create it like that is to use UITableView with cell that has UICollectionView inside it? It looks like it was created that way, but:
a. Is it the most efficient way to do that?
b. Because of the case in my first question is my source of confusion.
3. The bottoms section has a different separator from the middle section. The middle section has indentation while the bottom section doesn't. How can I do that if the case is it's a UITableView?
My whole question is just how to create a layout like that. If you cannot help me by providing me some sample codes that's fine, please just explain me the concept or theory of how to do that.
If the whole answer is just I have to create it using vertical/horizontal UIScrollView from scratch that's fine. I just want to make sure of that since I tried to avoid dealing with creating manual tiling.
OK, I think I finally found my own answer.
First, I need a UIScrollView to be root of the view. Then I set the contentSize to be a specific value.
The top section can be a UIPageController or a horizontal UIScrollView.
The middle section is a UITableView with scrollEnabled to NO and cells are static. The static cells (could also be dynamic cells) will contains UICollectionView. Since the scroll is disable, it will use the scroll from the parent UIScrollView. So that's why I can get the same bouncy effect in the middle section.
The bottom section is just another cell of a UITableView.
Thanks.
This might help you with implementing UICollectionViews in your UITableViewCell: http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell
To make the first cell "float" in the TableView you could make sure that cell never goes out of screen in scrollViewDidScroll

UICollectionView with growing header view

I currently have a UICollectionView with a header of a fixed size.
If you pull down then the header moves down leaving a gap above it between the header and the nav bar. The header has a button at the top, a couple of labels at the bottom and the BG is an image.
If you push up then the header scrolls upwards to display more of the UICollectionView items.
This is all working fine. However, we require a change to the behaviour.
What we want...
What we want is for the header to start off the same as it is now.
Pull down
But if you pull down the top of the "header" should stick to the nav bar and the header should grow.
I can do this easily by making the collection view frame smaller, faking a header and accessing the UIScrollViewDelegate methods in the controller.
Push Up
If you push up then the header should do exactly what it's doing now. i.e. stay the same size and disappear underneath the nav bar.
This last bit is tricky. If I go my proposed change for the pull down then it will make this much harder.
Question
How can I include both of these functions?
I'm thinking of maybe having a header but making it completely blank?
Another idea I just had... Make the collection view full screen but set the section inset so has enough space for the fake header. Then I can intercept the scroll view delegate methods like above?
I think this sounds best unless anyone has a better idea?
Can't you just make the header the desired (maximum) size but keep it hidden under the nav bar by calling scrollToItemAtIndexPath:atScrollPosition:animated: in viewWillAppear: of your UICollectionViewController?
As the UIScrollViewDelegate the controller could also take care of positioning the upper right button at the desired position while scrolling.

Resources