Why should I use a UIToolbar vs using a UIView? - ios

I'm building an instant messenger app in iOS. In particular I'm implementing the UI for a conversation in the most typical way, that is placing an input bar at the bottom of the view (UICollectionView to be clear) that scrolls above the keyboard.
Now, I'm wondering if I should implement this view as a UIToolbar with UIBarButtonItems instead of a custom UIView with UIButtons. What are the advantages of a UIToolbar?

I don't think there is much difference other than convenience. With a UIToolbar you get the following:
UIBarButton items are arguably simpler to add to a tool bar and the
layout is automatic, whereas it is a bit more complicated adding
buttons to a view.
You can set hidesBottomBarWhenPushed on the view controllers to
hide the bar when a view controller is pushed to the nav stack.
Looks more familiar to other apps, including Apple's own apps.
If you use a UIView with buttons you have more flexibility in the appearance but you have to do a bit more work, but other than that I can't really see much difference.

UIToolbar will provide automatic placing of your buttons, saving you from pain of placing those buttons. It was designed specifically for this reason.

Related

How do I create custom transition animations similar to Snapchat in Swift on iOS

We're creating an application with a design concept similar to Snapchat. On the base level, we have three Views that are supposed to be horizontally swipeable, with the camera view being in the middle.
The Views are also supposed to be selectable via a Tab Bar. While the views are being swiped, the transition should also manipulate the color of the Tab Bar aswell as the size of some elements on the Tab Bar, similar to how Snapchat does it:
Our UI Designer made a mockup for our specific application in Adobe XD:
The button has been made independent from the Tab Bar, as it is supposed to do some interaction with the controller beneath, even if the Tab Bar disappears.
I've been trying to figure out how to best implement a navigation like this for about 10 hours now. I've come as far as trying to create my own AnimationController for animating between Tabs coupled with a custom InteractionController, but those have been unsafe and buggy at best, and I still haven't figured out how to animate the button at the same time as the views.
Has anyone tried to implement a design similar to this and succeeded? Could you lead me in the right direction of which methodology to use to achieve a design like this?
Thanks in advance everyone.

Expand/collapse UITableViewCell to achieve Evernote-like transition

I'm interested in achieving a transition between view controllers very similar to the transition in Evernote's iOS app:
When "Places" is tapped, it smoothly expands into what looks like UINavigationController with a green border around it. To collapse it, I can either tap "Back" or swipe from the left side of the screen to gradually transition to the home screen.
I'm not looking for exact code samples to copy-paste, bur rather for high-level guidance on which concepts and Apple APIs to leverage. More specifically,
Which transition/animation APIs does this likely use?
How can I achieve the green border around the entire view controller once "Places" is expanded?
I think it uses a custom transition for the zoom in effect. It can be achieved by using this 3rd party framework: https://github.com/mluisbrown/LCZoomTransition as a pattern since the destination view controller looks like a modal and not a destination view controller.
An approach to consider: you can use a UICollectionView with two different layouts. The unexpanded layout can just be a UICollectionViewFlowLayout and the expanded layout can be a subclass that shrinks/fades all the cells except the one you want expanded. Then you can use setCollectionViewLayout:animated: to switch between them.
The green border would just be the background of the parent view, since this wouldn't involve a UINavigationController.
And if you want the interactive swipe gesture for going back from the expanded layout, you hook up a UIScreenEdgePanGestureRecognizer to an interactive collection view layout animation (see startInteractiveTransitionToCollectionViewLayout:completion:).
Judging by that border around places in full screen I would say it's not a UINavigationController but rather two view controllers with custom transition between them.
This was introduced with iOS7 and you can find few tutorials online to implement any custom transitions:
http://www.objc.io/issue-12/custom-container-view-controller-transitions.html
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIViewControllerTransitioningDelegate_protocol/index.html

Custom UITabBarController with Scrolling

I am developing an application that requires a scrolling UITabBarController. The customary 5 tab items max with the 5th being the More.. tab just won't do. I have found some pretty great third party classes such as https://github.com/Marxon13/M13InfiniteTabBar and they are great and have the functionality I would like but still, things aren't perfect. When I rotate my device to landscape things become glitchy.
Basically, I am fed up and want to create my own custom UITabBarController with scrolling..how would I go about doing this? I understand I would most likely put a UITabBar within UIScrollView but I am lost without a detailed tutorial of sorts..
Any help would be greatly appreciated! Thanks!!
The way I would approach this is to avoid modifying the UITabBar, since it is highly specialized, and create a UIViewController subclass that will provide this functionality for you. This view controller should have a container view (take a look at this Apple documentation for more detailed information) that will have each child view controller's content view.
For the actual tab bar itself, you have a few options depending on what you similar you want it to the standard UITabBar.
You could have a super basic tab bar that consists of a UIScrollView with standard UIButtons that change/load the correct content view controller. Creating the tab bar would be then easy, simply add the buttons to the scroll view inside some type of loop (you could have the x positions be a multiple of the tab index to make positioning easier). UIButtons have support for a selected button state that you can use. You can change the scroll view's background.
You could have a fancy tab bar which is constructed essentially like the above, but by having a custom UIButton subclass instead of a standard UIButton. This will allow you to implement a more intricate design (i.e. with and more customized touch handling.
Tips:
Use [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] to have your tab images tinted like the standard tabs when selected.
Design the basics of your custom view controller in your storyboard. It is really easy to add the child container view and the scroll view this way.
Hope this helps!

HMSegmentedControl (custom tab bar controller) switching subviews feature

I'm looking for a way to use HMSegmentedControl inside a UINavigationController, using the tabs to change the subview. That is clicking on a tab should display the corresponding view below the UINavigationBar and the HMSegmentedControl tabs. If possible, using as much as Storyboard features as possible.
I have made several attempts, by inserting the views as outlets. The further I got is to have it running by using when detecting a tab selection change (and removing the other subviews obviously):
insertSubview:(UIView *) belowSubview:(UIView *)
but it cuts the upper part of the subview (the one overlapping with the HMSegmentedControl tabs bar) and also makes the non-initial views not behaving well in terms of autosizing (for instance when rotating the screen).
Are there best practices for implementing such custom upper tab bar controllers inside a navigation controller (and not the opposite because of another dependency I am using)? Or better yet is there an easy way to do what I am trying to do using Storyboards?
I think it is better to juggle controllers than views.
I would have several controllers with identical navigation bars. That is an identical HMSegmentedControl in their bars.
As the user changes the selected segment you switch controllers and make sure to adjust both the exiting and entering controller's segment control state accordingly.
You could also try to have all navigationItems to point to the same HMSegmentedControl instance and see if it works.

Xcode - Sliding Tab Bar? [duplicate]

I've downloaded an Download Manager from App Store and noticed that the app scrolls an UITabBar,like: When the user press a button the bar walks left and show other option to the user.Is that really possible and does Apple accept these type of customization in UITabBar?If it's possible how can i do that,please provide some sample code or reference.
Yes, possible. but not using usual UITabbar. you have to create custom tabbar that behave the same. there are projects out there that you can use, save a lot of time of your work.
infinitetabbar : A scrolling tab bar with space for infinite items
jsscrollabletabbar : JSScrollableTabBar is a simple, refined tab bar UI control that resembles the TabStrip found in the popular Three20 library but without any of the dependencies.
It is probably a custom-made control (a scroll view with a few child buttons). It's perfectly acceptable at the Store if you don't use any undocumented functions.
Yes, you can implement scrollable tabbar using UITabBar.
Adobe writer maybe thought about using only UITabBar, so he mentioned it can't be implemented, but if you use ScrollView and UITabBar, it can be implemented.
Put tabbar on scrollview, scrollview size is 320,460 (it excludes status bar size).
TabBar size is any size you want, scrollview contentsize must be equal to tabbar size.

Resources