I'm interested in how to show/hide UIView when dragging and cling to the borders. What the method it was implemented, UIKit-UIDynamics?
-
I haven't tried anything. I just want to find right way to implement it. I have one idea about using UIAttachmentBehavior and UICollisionBehavior, but I'm not sure that it's right way. – Tikhonov Aleksandr Sep 06 '15 at 08:09
2 Answers
You need to animate a height constraint of the temperature label (or custom view, I don't know what that is).
So, just link an IBOutlet to the height constraint and animate it
func animateCloseWith(float: CGFloat) {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.myConstraint.constant = self.myConstraint.constant - float //for the height
self.myView.alpha = Float(float) //for the fade effect
})
}
then just call it from the scrollView delegate
optional func scrollViewDidScroll(_ scrollView: UIScrollView) {
animateCloseWith(scrollView.contentOffset.y)
}

- 1,634
- 2
- 18
- 32
First of all:
Consider looking on the web for your solution before asking here on Stack!
I was developing an app in the past and found a neat solution for this. If you ask me: This repository looks exactly as the Yahoo-weather app which is about 90 similar to the apple weather app.
It is written in Obj-C
, therefore I would suggest using Obj-C
to implement it.
You just need to customize the views to get the clouds, suns, labels, horizontal scrollViews
and all the other stuff.
To show/hide a UIView
you could simply use scrollView.contentOffset
in the scrollViewDidScroll
method to show/hide the desired UILabel
/UIView
!
Check here: Get current position of animated scrollview
Download the project and run the samples to test it! :)
Here you got an additonal screenshot:
Cheers!

- 1
- 1

- 1,377
- 3
- 16
- 40