Search code examples
iphoneobjective-ciphone-sdk-3.0uitouchcgaffinetransform

Smooth rotation of UIView with touch


I'm wondering how to smooth a UITouch in my code. I am able to detect the UItouch on my UIView, but when I try to rotate the view using CGAffineTransform, it does not rotate smoothly. I have to press or long finger touch on iPhone for this kind of rotation. How can I perform smooth rotations, like Roambi Visualizer app. Thanks for your help.


Solution

  • transform is an animatable property of UIView, so you can use Core Animation to make the rotation smooth:

    CGAffineTransform newTransform = //...construct your desired transform here...
    [UIView animateWithDuration:0.2
                     animations:^{view.transform = newTransform;}];