Creating a collapsible navigation bar in iOS - ios

I wish to create a collapsible navigation like the one shown in the video linked below (the screen cast is for the android version of the app).
screencast
I'd like to know what classes I should use to accomplish this effect. Also note that the tagline "I am the founder" can vary in length so the expanded layout can vary in length. How would I be able to size the expanded nav bar dynamically (the only example I found had static sizes for the expanded and contracted states)?

Cool question. The best way I can think of would be to not use a navigation bar. Best would be to use a UITableView, have three cells, as shown here:
When the user scrolls and the top cell disappears, you can animate out the second cell as shown in the video using custom animation and viewWillDisappear (tableView protocol function).
Then have a fourth cell you design that appears. This fourth cell is the navigation bar that the user sees after scrolling. Keep this cell at the top until the user scrolls to the top.
Hope this helps!

For this purpose, you can use 3rd party cocoa pod. The link is given below.
https://github.com/vicentesuarez/Swift-FlexibleHeightBar

Related

How to create table view with rounded corners around the list items

I am trying to recreate a menu similar to the ones in the detail view of the iOS 13 Health app. Please refer to the marked up screenshot.
I know that this can be done with a table view. There's a section title and list items. But what I want to achieve is similar to the look shown in the screenshot whereby there's a background colour on the list items (not including the section title) and rounded corners at the top and bottom of the list.
Can anybody tell me how I can achieve this with the table view? Or point me towards the right direction? I already know how to setup table views and programmatically add the details. I just need help on how to achieve the styling as shown below.
Thanks!
So, I was able to figure it out. For the benefit of the devs who stumble in the same dilemma, I'm posting my solution here. But I will be tagging Glenn's answer above as the correct answer as it lead me to find the solution. Thanks again Glenn!
It appears that I didn't have to do anything special with my code. I just discovered that on XCode 11 and iOS 13, there's a new table view style called "Inset Grouped". You may set this property from IB or via code.
With a quick experimentation I was able to come up with the result as shown on the screenshot below.
It's not that complex to do. This one of the multiple ways that that style can be done.
a. You can use grouped tableView, as what you've indicated in the screenshot.
b. Provide section title, or better yet, a section view (for more customization!).
c. For each section, you have ONE tableViewCell.
d. For each cell of that c., you will have a tableView.
e. For each tableView of that d., you will have your a new cell of course (item cell).
f. How to compute for the height of the tableView of e.? There are multiple ways.
Provide static height (if your number of items are static).
If dynamic count, but you have constant height of each cell, then you can just compute it like so: itemsCount * heightConstantOfCell
If again you have dynamic count of rows/items, and you have iether constant height of each cell or dynamic height of each cell, then you can observe the frame key of the whole tableView.
g. Finally, just add some corner radius to each container view of your tableView in d..
Note, this screenshot ONLY shows the item g.. It's merely a corner radius of each container view of your tableView in a tableViewCell that is a cell of your main tableView.
Another way is to use UICollectionView, but kinda more complex than what I've discussed - at least for me.

How to add UITableView cell pagination with “peeking”?

I want to add something like what’s in the app store app:
As you can see, it isn’t just one cell that is paged, but you can also see the two edges of the cells from the left and right as well. I tried to implement this in my app by making each cell slightly smaller than the size of the collectionView, and then enabled isPagingEnabled, but when I flipped from cell to cell, it didn’t page from cell to cell, rather the width of the entire UICollectionView every time. This ended up in an unwanted effect where each page turned resulted in an increasing offset where cells were shifting further and further off the screen.
I researched a bit on this and implemented the targetContentOffset(forProposedContentOffset... but it was never called and didn’t work.
Preferably, I would want to keep the smooth behavior of the built-in pagination and just be able to tweak it.
Thanks!
Instead of implementing the peeking behavior yourself delegate it to a third party library iCourasel. Implementing it yourself you will ended up a UICollectionView inside of UITableViewCell. As of your requirement iCarouselTypeLinear suits your requirement.

Create hidden cell under UItableview in Swift

I am not sure if the title make any sense, but I do not how else to describe it in few words.
I have a simple task I want to do. I have a UItableview in my viewcontroller. I want to create a little nice effect, so when you get to the bottom of tableview and scroll a little further down my logo / some tableviewcell will appear. When you release the finger the tableview will scroll back up to the "real" buttom.
I have searched on google and here but cannot find any solution to this.
Please ask if it is not described clearly:)
It is an effect that is seen in other apps, but I cannot remember the names unfortuantely. Will try to find example.
You can use Footer view for your logo in table view.
As Anil said I also got the idea of using the Footer view, but it doesn't provide solution for scrolling out of the box.
So I think the best thing is to set your logo as the backgroundView (but so that it is placed in the bottom of the page) and then to set backgroundColor of your cells to white (or whatever color you want to use). It should work exactly like you want.
Would UITableViewHeaderFooterView be what you're looking for?
From Apple docs:
The UITableViewHeaderFooterView class implements a reusable view that
can be placed at the top or bottom of a table section. You use headers
and footers to display additional information for that section.
Check out this blog post.

If I have different UI controls to display sequentially, should I still use a table view controller?

I want to implement something similar to this- (focus on the left portion)
I imagine possible implementations to be
Making a table view with (in this case) 7 'normal' cells, one normal size cell with a custom right accessory item, one 3XL cell containing a button, and finally a normal size cell with an imageview and custom accessory item.
or
Making a scroll view with styled view containing UILabels masquerading as 'cells', a button within a larger UIView, and another faux view-with-label-cell.
Considering the challenges posed by different screen sizes, and the want for easy configuration and modification- which way should mixed sequential data be displayed? Hacky table view, redundant scroll view, or reinvented custom UIView?
Edits
I am currently using a sliding view controller. The sliding functionality is of no worry to me, the contents of the scroll/table view within is.
There are various open source libraries available on net/github. you can use this https://github.com/edgecase/ECSlidingViewController.
Although you can make your own if you want but doing this using scrollview I don't think it will be a good way to do that.
Edit
You basically have to create 8 normal cells and change the color of the cell label which is selected. And create a footer view of YUTableview for last view.
You can use Slide-Out Navigation Panel. Use this slide-out-navigation for better understanding.
I've found more information on this, and I definitely overcomplicated a simple matter.
The answer is yes (use the table view), and there are multiple reasons- the first being the principle of always using the highest level of abstraction where practical.
StaticUITableViewCellsare completely capable of rendering other UI elements (buttons, sliders, etc) inside themselves from stock, and this is encouraged in Apple's UITableView spec. Dynamic cells, stock, are not as flexible but they can be subclassed from UITableViewCell for more custom functionality.
To speak for the example, the first X (in this case, 7) cells are likely dynamic, and the last 3 cells are static. The 'second to last' cell seems to have an infinite(?) height, and the last cell appears to be a sticky tableview footer.

Custom grouped table or buttons?

I'd like to design a view like this:
Each "section", which looks like a two-cell section in the mockup, are actually or should behave as a whole, I mean, both the blank upper part and the lower part with the disclosure indicator should be an only tappable unit and navigate to another view, I drawed it like two cells because I need the disclosure indicator to be vertically aligned to the bottom.
Should I set two grouped table views with three sections each one? Is it possible to change the corner radius of a grouped table, the space between sections and the right/left margins of the table? And change the alignment of the disclosure indicator?
Or should it be better to design a view like this with buttons? Is it possible to put a custom disclosure indicator in a button, or such symbol is only intended to appear in table cells and may break the iOS Human Interface Guidelines?
Thanks!
Collection views is the best for this.
Each little box with be its on UIView, reminds me of the card app they created in iTunesU, coding together.
Hope that helps.
UICollection view is the best but if you need to support iOS5, in that case you can use plain UITableView create a custom UITableViewCell with the contentView you want with appropriate padding.
I made something like this some time ago.. There are 2 options for you to develop this..
If you are supporting iOS 5.0 and below then you can make a grid view using TableView. (The code is in this tutorial http://www.edumobile.org/iphone/iphone-programming-tutorials/images-display-in-gridview-on-iphone/). Customize it a bit for your button and ImageView size.
If you are only supporting iOS 6.0 and above then you can use CollectionView and then customize it according to your needs.

Resources