Animating an UIButton on an UIScrollView - iphone

I'm having problems animating my button in my scrollview. Basically what I'm doing is moving the button down the y-axis when the button is pressed down and moving it back to it's original position once the press has stopped. My code itself works just fine and does exactly what it is meant to do. Oddly enough, it only does so on a regular View. On a scrollView, it only moves it down after a short delay after it is pressed and the animation is very choppy. I know that there's nothing wrong with my code and that's why I'm so confused. Does anybody have an idea on how to fix this? Any help would be greatly appreciated!

Not sure how to make what you want work, but I am pretty sure the "choppy" behaviour is a result of the UIScrollView touch being recognized and activating what it is meant to activate (i.e pan gesture). One idea that comes to mind is to disable scrolling when this action is performed.

Related

Pausing and restarting animations

I'm working on a test that uses swift UIKit dynamics to animate a ball across the screen. I want to add a button in the top left of the screen, that when pressed, pauses the screen just how it is, then when pressed again, resumes the animation. If anyone has any suggestions on how to go about doing this that would be much appreciated. Thank you
The simplest thing to do is to set the speed of the layer of a superview that contains all views being animated to 0:
self.view.layer.speed = 0
Then set it back to 1.0 when you want the animation to continue.
(It isn't obvious that layers have a speed property. It is there because they conform to the CAMediaTiming protocol.)

adding swipe gesture to view controllers on storyboard not working

I am pretty new to this so i was following this tutorial.
www.youtube.com/watch?v=5u1-DGiUhXU
I have 4 view controllers with images etc. And i have done exactly as per this video. My problem is, if i tap, drag do anything nothing happens. I am just stuck at main screen. I have tried changing push to model but it don't work either.
Any Ideas?
You should set your imageViews UserInteractionEnabled = YES to enable touches cause it is =NO by default. Just solved similar problem this way.
EDIT: I've just repeated the actions described in video and everything works fine! You really should follow the video guide carefuly!
P.S. The swipe gesture should be a quick move from the left side of screen to the right.
I saw the same tutorial and I had the same problem and i solved it as follows:
When dragging the Swipe Gesture Recognizer u MUST drag it into the view itself(where the background color apears).
When it wasnt working for me i was dragging it to the Black bar on the bottom.
Hope this helps.

Pinch to grow/shrink the size of a button

I've a few button on my screen which can be moved around ok, but I was wondering has anybody ever implemented a pinch gesture on a button to shink and grow the button?
If anybody has any ideas/help/examples of implementing this kind of functionality it would be greatly appreciated.
I'd add a UIPinchGestureRecogniser to the button, and then apply it's scale property as a transform on the button's frame.
I don't have sample code, but that is the area I would look at to accomplish this.

UIScrollview scrolls back down when tapped

I have a weird issue which I'm sure someone can help fix easily. I have a UIImageView within a UIScrollview which I'm able to scroll up to the top. I have paging enabled and it's working as expected except for one problem. After I scroll the image all the way to the top and it snaps, as soon as I touch anywhere in the UIScrollView, it automatically scrolls the UIImageView back down. Any ideas on how to prevent this?
Thanks!
Fixed the issue by playing with the UIScrollview's content size.

How can I do this iPhone (segmentedcontrol?) layout?

Please look at this screenshot:
When you tap in another segmentedcontrol, it switches smoothly (try it if you can).
First of all, is it a segmentedcontrol?
Second, how can I add this smooth effect?
Thanks guys.
I just tried. It does not seem to be a segment view.
Maybe 3 dark buttons(or view or views) and a layer that moves and overlay the current selected button.
Everything is well crafted so it looks great ;)
I think I could do that with a big UIImageView (instead of the three buttons) with an UITapGestureRecognizer to get the touch and a CALayer for the selected button