make transparent stickyHeader like weather iOS - ios

i want to create transparent sticky header like weather app in iOS as my header is transparent view goes under header but i don't want other content visible bellow my header. ( you can see "Friday" goes under header and will hidden but the header is transparent).
you can check the animation and this behavior in weather app.
i have tried :
CSStickyHeader

This is done with a combination of various scroll views and table views.
It looks like the whole screen is contained in a UIScrollView. The "header" is just a UILabel that moves depending on the content offset of the scroll view.
The time bar with "Now", "02", "03", ... Is probably a UICollectionView inside the main UIScrollView.
The section underneath that is a UITableView with all the day information. This is also embedded inside the UIScrollView.
The scrolling is then managed by the main UIScrollView and passed down to the UITableView.
However, when the tableview scrolls it is not going underneath anything. The content is being cut off because that is the top of the UITableView.
Then the entire thing is also embedded inside a UIPageViewController to manage the pages.
Something like this...

Related

How to make header only stick on negative content offset - Swift

I have a tableView and I have a UIView as the tableView header. I want the header to move up the screen when I scroll down and act just like any normal cell. But when I have reached the top of the view, where if I scroll up it will just bounce back, I want the tableView header to stick to the top.
One example is like the Facebook app headers. They scroll when you scroll, but if you're at the top of the page and you scroll up, they wont scroll down, they stay stuck to the top.
How do I achieve this?
If you're using a normal tableView (not grouped style) and you only have one section, you can accomplish this by using the section header instead. The default behaviour of this type of tableView is as you described. You'll just have to provide a custom view for the section header that looks like your cell.
If this isn't a possibility, you'll need to take advantage of tableView being a subclass of scrollView, and implement the scrollViewDidScroll delegate method to check content offsets etc.

Move views under ScrollView on pull to refresh

I have a layout like on the picture bellow. On it I have:
general header
tabs
table
Depending on the selected tab I display UITableView with different data.
I need to implement pull to refresh functionality for the screen. I just didn't want to invent a bicycle and tried to use UIScrollView, but I can't use it as container for the whole screen, because the UITableView already has is own UIScrollView. Thus I wrapped the header into a UIScrollView, but when I do pull to refresh the header moves behind the tabs and the table.
Can anybody advise how to move views under UIScrollView when I do pull to refresh in the UIScrollView, but do not hide content of the header behind Views below? Or how put UITableView inside UIScrollView in a safe way.
For this you can drag and drop UIView in UITable View Just uper the cell. Then You can use that UIView acording to you.

iOS UIScrollView with UIWebView and UITableView in Storyboard

I have a complex design to create. I want to have something like this
- UIScrollView
--UILabel
--UILabel
--UIWebView
--UITableView
--UITextField
--UIButton
I am using a Storyboard and I want the ScrollView to take the height of the Full Webview and the TableView so that there is only one parent scrolling and other scrolls are disabled and the whole page seems like one single view.
Right now, the whole UI looks very messed up and only the Webview and table view scroll indivisually and the parent scrollview not scrolling at all making the labels and textfields have a constant place and the button not showing at all.
EDIT
Using raki's solution, I used a TableViewController. I have something like below:
But the webView does not cover its full content and just shows in the area shown in the image.
How can I solve this issue?

How should I approach structuring this view?

I'm having a hard time finding the best way to structure this design.
The top view has a minimum height and becomes sticky when it reaches this height. The bottom view hosts a paging controller with three views within. Each of these views hosts either a collection view or table view with vertical scrolling.
I'm really at a loss on how to approach this. Is the entire view scrollable and I should prevent scrolling on the second view until the top view has reached it's sticky height? Or are each of these views separate uitableviews and the pagingcontroller is just one cell? Should I even be using a pagingcontroller or should I use a scrollview with paging enabled? (the latter was a little rough interaction-wise)
Thank you!
Take a look at the Advanced User Interfaces using Collection View from WWDC this year. This view is very very very similar to the iTunes Connect app interface. The entire session video explains how they created that interface.
I used a similar method to this to create the keyboard in the Emojicate app.
I think what I'd do is actually fake the sticky header. So something like this...
Use only one collection view.
Create a "segmented data source" that contains three data sources. (See the video from WWDC about this)
When the segmented control is changed then update the collection view by changing its layout and (if you want) dataSource.
Make the entire top section a header on the collection view.
When the collection view scrolls past a certain point (when you want to sticky the header) then have a second view that is the compressed header and make it visible at the top of the screen. This is not attached to the collection view at all.
When the segmented control changes you can update the collection view by changing the "selected datasource". The datasource can also contain a UICollectionViewLayout that will update it.
Essentially, the tableview you are talking about is just a collection view where the cell width is equal to the screen width. i.e. fake a table view.
The sticky header isn't sticky at all. Just when it starts to go off screen you can put a fake header there instead.
It will require a duplicate (ish) view and some thinking about how to structure the data but I think this will be easier and less resource hungry than having multiple collection views and page controller and stuff.
If you want me to go through it in more detail let me know but it's a complex subject. Watch the video first.
I would make this part a navigation bar. Should be relatively easy. Just have to customize the back button with a barButtonItem and do a couple of labels in the titleView.
I would make the next part a Table View.
The tableView has 2 sections. The first section doesn't have a section header and the second section doesn't have any cells but just a section header.
First and only cell in this section:
And the rest would be the second section header's view:
This gives you the stickiness that you want because the section header will remain there even if you scroll past it and since the collection has only 2 sections the controls will always remain on top.
I think the collection/table paging part is the hardest part and I don't know clearly how it can be done. But I was thinking it could perhaps be a ContainerView. Each view of the container view would be either a tableview or a collectionview. You would have to add some code to handle the movement of the containerview relative to the second section header (possibly an autolayout constraint that attaches the containerview to the buttom of the first tableview that you implemented above).
I don't think having your tables/collections in a scrollview would be a good implementation. I think I have even read in documentation that developers should stay away from that (but I might be remembering it incorrectly).
I would have:
A "header view" with three subviews:
Fixed height top and bottom views (they stay visible at any size).
A middle view that appears/disappears as the superview grows/shrinks.
A scroll view (table or collection view are subclasses) on that partially covers the header view with a top inset set enough to reveal the underlying header view (the same way pull to refresh views are revealed).
The paging buttons could be set as table/collection view section header views.
Finally track the scroll view's scroll position to keep manually adjusting the header view height.
Another way to see this solution.
Two completely separated parts, a header view and a table view.
A simple header view (blue) that adjusts its subviews as its height changes. More precisely hides its middle subview (light blue) when it shrinks.
A table view that a) partially covers the header view in Interface builder but b) has a top inset as to avoid hiding the header view in the actual device (tableView.contentInset = UIEdgeInsetsMake(60.0f, 0.0f, 0.0f, 0.0f);).
The two parts are only "connected" by resizing the header view height as the table view scrolls up/down.

UITableView with header works incorrectly for any view except UISearchBar

I have standard master-detail navigation based app with first VC as UITableView. I want almost standard UITableView with custom tableHeaderView (UISearchBar enhanced with additional button).
First I have tried to set UISearchBar as header view and everything works just fine.
But when I set a custom view (even simple empty UIView) as tableHeaderView, table begins to behave wrongly:
Header view scroll offset is not adjusted automatically (i.e. header not automatically slides up or down)
When push to another view controller happens, UITableView scrolls to Zero contentOffset, which is noticeable by user
This is strangle because UISearchBar being set as header should not affect tableView scroll logic.
Maybe apple uses some hidden APIs?
Anyway, is there a way to make custom header that works smoothly like with a SeacrBar (without side effects)?

Resources