I'd like to create a dial with s开发者_JS百科imilar behavior to some of the retro phone apps. These have a circular dialer that lets you spin it around with your finger. Any ideas how that is created or some links that discuss aspects of it?
Create your circular dial with numbers on it. Create your moving dial part as a transparent image centered over the number dial so you can see the numbers through the transparent holes. Apply a small image for the finger stop over both. When you get a touch in one of the hole regions track the motion of the finger. As the finger moves rotate the transparent dial image to follow it using a transform matrix. If the finger moves the wrong way or when the finger is lifted or moves outside the rotating dial the dial is "released" and you undo the rotation using a suitable speed to simulate a spring loaded return.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:d];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationBeginsFromCurrentState:YES];
CGAffineTransform transform = CGAffineTransformMakeRotation(/* some angle */);
image.transform = transform;
[UIView commitAnimations];
Detecting the actual number dialed could be done a number of ways, from creating invisible buttons on the dial and grabbing events from those or by calculating the angle of rotation required to return the rotating dial to home. I don't think implementing it would be very difficult, it's the artwork that would be hard.
精彩评论