How do I animate a view on touch? - ios

My scenario is common I think. I want to animate a focus reticle (just like Apple's default app and some of the other camera apps out there). Is this all done in drawRect:? Or can I use the animation framework right from the touch handler?

Following some of the examples around github (and the internet) I went ahead and just subclassed UIView (drawRect:) and a little simplistic "animateWithDuration:".

Related

iOS: How to code a Tool Tip when user hovers over a UIView

I would like to have a tool tip show up over a set of UIImageView when a user hovers over it. I don't see see any methods to leverage that do this in the UIImageView class.
How can I accomplish this?
Tool tip support is not directly available in iOS at this time. But you can accomplish the same effect with a couple of approaches:
Using an existing tool tip framework
There are open source solutions available that solve the problem, which you can pull into your own project and use and save a lot of time, as long as you ensure the license is compatible with Apple's policies (many of them are, but require that you credit the author somewhere in your project source). You could study their code to learn the technique. For example there is AmPopTip project on github
Here's a corresponding YouTube video:
Here is a similar StackOverflow.com question (there may be more):
Is it possible to show a tooltip in an iOS app?
Trying to code it yourself
You'd probably use a long press gesture, see Apple's Gesture Recognizers documentation and perform some kind of Hit Test to determine when the finger was over UIView subview (in this case UIImageView) and then time the entry of it, and how long it was held in that view without moving out or lifted.
At that point you'd want to overlay a UITextView or a class that contained one but drew a custom border around it, containing with the tool tip by either adding it as a subview over the top or near where the finger was placed, or make it the pop up as a separate UIViewController.

Animating a "character" within iOS app that's not SpriteKit

I am in talks with a client to do an app, but in it, they are wanting it to revolve around a little character that follows you throughout the app (think Clippy, from the old days of Microsoft Word :)).
One thought I had was, can I use an SKSprite/Node inside an iOS app not using the SpriteKit framework?
Or is this a matter of animating through an array of UIImages?
Those were my first thoughts - does anyone know the best direction to go in for something like this? I need basic animations for a character throughout the whole app.
Depending on the detail of animation needed, you could do it with just CoreAnimation and possibly selectively choosing the image to display in an UIImageView. For example, see the answers to this question: rotate a UIView around its center but several times
Simple answer is, No, out of the box you can't use a class from a framework and choose to not use the framework. Though I'm not exactly sure what that question means. An SKSpriteNode renders via an SKScene node, and an SKScene node renders via an SKView, which is rendered by a View Controller.
You could do something fancy like dedicate the SKView as only part of the screen, and have a standard UIKit view as the other part, or only have the SKView appear on the screen when you needed it I guess.

iOS: Facebook chat heads behaviour and animations

This question is probably a little out of date, but I've been using the new Facebook for iOS with the "chat heads" feature (with the chat heads only present within the app), and was wondering how Facebook went about implementing this? E.g. How did they handle the drag animations for the chat heads, and also (when clicking on the chat head) how did they manage to overlay a UITableView on top of the "base" UIViews in the background?
Is this all part of UIKit, or did they create their own classes to handle this?
To answer #StuartM's question in the comments, in the last couple of months I've had a bit more experience with UIKit, and I think I have a rough idea on how I would implement something like this if I was going to do it.
What I would do is for the chat head, create a styled UIButton and add it as subview to the main Window. For the dragging, I would add a Gesture Recognizer to the UIButton to respond to the drags, and for the "snapping to edges" I would use iOS 7's new UIKit Dynamics (http://www.raywenderlich.com/50197/uikit-dynamics-tutorial).
As for showing the UITableView overlay with the chat history, I would use a Child View Controller (https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6) and as for the popping open animation, I would just use the default UIView animations, maybe using animation transactions as I'm not sure I can do everything with just the implicit animations?
And I think that should be it. To be honest, I think anyone who has a handle on those frameworks should be able to build anything in their iOS apps, and if you were to create a "chat heads" like sample project in your spare time, should give you a pretty indepth knowledge of how those frameworks work.

iOS - View Transition open and close

In the latest Expedia app for iOS, they have a very interesting effect that I am trying to wrap my head around.
When you tap on any tile it flip and zoom animation.
Can you please help me for the same for UIView transition.
I've wanted to use this kind of animations in my app as well, so I have written a simple custom segue that does just that - you can even choose between multiple types of flips!
It's called IBCellFlipSegue, give it a try and let me know what you think!
https://github.com/IBLabs/IBCellFlipSegue

Build a "grouping" animation like Apple's iPad mail app

How can I do this "grouping" animation like Apple mail or the Gmail iPad app?
Does this need to be hard coded, and completely done with the animation framework, or does Apple expose an API for this to be done. I checked the developer docs, and I don't see anything like this. But Gmail was able to exactly replicate Apple's animation, and that's why I am curious to know if it can be done in an easier way.
I am 95% sure Apple does not have a UIStackOfPaperViewController or anything like that. You would have to code this up yourself.
Conceptually, it isn't too complicated: a background view with a texture, and each subview tilted at a random angle and a drop shadow beneath. You could do the drop shadow by drawing a gradient in a view around the "real" view. Core Animation's default behaviors would probably do the right thing, e.g. if you create the page view off screen and then set the final location, it will fly onto the stack pretty much how you would like it.
If you don't need support for releases earlier than iOS 6, there's probably good stuff in the Collection View Controller to make this easier.
Hopefully that's enough information to get you started, but your question is really broad. It's difficult to answer "How do I do X?" if you don't specify your starting point, or answer "How can I do this in an easier way?" if you don't specify what you think the hard way is first.

Resources