iOS Stackview Tap Buttons on top of each other - ios

I have a stackview that I am using as a dropdown menu by changing the spacing to collapse and expand the stack view.
There are buttons inside the stack view of the same size. When the spacing is negative they appear on top of each other. I set the layer zIndex to determine which button I want to show on top.
I was hoping this zIndex would also determine which button receives the tap notification but instead the last button in the stack view always receives the tap.
How can I make sure the visible button (with highest zIndex) is receiving the tap?
Is there a better way for me to implement a collapsible menu of buttons?
Best regards

If you are using stackview and want to show/hide the button conditionally, then while hiding button, also write:
stackView.removeArrangedSubview(buttonInstance)
buttonInstance.removeFromSuperview()
Instrad of buttonInstance.removeFromSuperview(), also try buttonInstance.isHidden = true

Related

Is there a way to make the twitter's iOS app's notification tab's navigation bar (pic attached)

I am thinking of implementing a UISegmentControl extension to achieve the twitter's iOS notification tab bar, navigation bar segment style. I tried extending the class like in this post.
I want to be able to control the size of the underline that scales based on the text's width, just like in the app.
Any ideas or suggestions are appreciated.
Yes
Have a top row section:
Icon | Notifications | Settings Icon
Then a bottom row:
All | Mentions
You make a container for each section in the bottom row that takes 50% of the width of the row and then have a block inside each section for the text. The width of block should only be as wide as the text so that when you add a bottom border to it, it only spans as far as the text goes
You can create your custom Top Bar.
Add two views each containing your label with text, below that label add a view whose leading and trailing constraint from label. add both of these views in Stack View and fill equally. For tap you can use TapGesture or UIButton.
Use collection view for dynamic tabs.
UIPageViewController below for different screens.
I have attached a screen i designed for reference
XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers. Pan gestures can be used to move on to the next or previous view controller. It shows an interactive indicator of the current, previous, next child view controllers.
https://github.com/xmartlabs/XLPagerTabStrip

How can I allow tapping on button outside cell frame?

I have added cross button on the edge of collection view cell and half part of this button gets overlapped by the cell below it. How can I make the lower half for this button tappable?
Edit:
Is there anyway we can change the zposition for button or we can make it appear above the collection cells?

UIPickerView modal with already visible toolbar attached

(See Sketch)
How would I implement this behaviour with an already visible toolbar? Also, the little information I found on opening a UIPicker modal are all based on using a UITextField which is not what I'm aiming for.
What I'm looking for is a button on the toolbar opening the picker modal with the toolbar attached to it. Button1 on the sketch is simply to select a value the user is most likely to pick (Something like "Go to todays date"), and done should hide the modal and bring the toolbar back to it's original state of being attached to the bottom of the screen.
Ideally, I'd like this toolbar with the picker functionality to be avaiable on multiple views.
You could add constraints to your storyboard, connect them as outlets to your code and then disable and enable the appropriate ones whenever needed.
One constraint setup would be:
add a constraint that pins the top of the picker to the bottom of the view
add another constraint pinning the bottom of the picker to the bottom of the view
-> If you enable 1 and disable 2, the picker is hidden
-> If you enable 2 and disable 1, the picker is visible
That change in constraints is animateable which will result in a smooth UI change.

tab view like button slides up

I am trying to have a button that is located on the bottom and when the user taps on it it will slide up to show the menu. How is this possible using code or is there an api or anything that I can use to make this possible in the easiest way?
Your screenshot shows a view whose frame is animated when the button is pressed so that either the height of the view, or more likely just the position, is changed so that the view becomes visible. This is a simple UIView animation and the view being added so it is hidden behind the button initially.
Check out the iOS documentation for Animating Views https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html
You should be able to create the view and its content either with the interface builder or in code. Start with the view off the bottom of the screen and then use animateWithDuration:animations: using the frame property.

iOS/Swift: Dynamically Resize a Toolbar

I'm trying to make an app with a toolbar that can be resized. Basically, the toolbar can alternate between being at the bottom of the view and being at the top. When a button is pressed, it switches from one to the other. The problem is that when it is at the top, I want the size of the toolbar to expand to accommodate the status bar, but I don't know how to do this.
I've seen some solutions for changing the toolbar size but they all seem static and not something that can be changed with the tap of a button. Any suggestions on how to do this? Perhaps a different solution altogether?
You can use a normal UIView and customize it so it looks like a UIToolbar, then just set constraints using AutoLayout and animate the height-constraint.

Resources