how to rotate uiimageview at certain angle?

Discussion in 'iOS Programming' started by rahulvyas, Feb 4, 2010.

  1. rahulvyas macrumors newbie

    May 6, 2009
    Hello all,
    i am new to iphone development.
    i am creating a game in which we have to hold a cup(UIimageview) while holding when i move my finger to right then rotate cup slightly to left and if i move finger left rotate cup to right.So what is the best possible way to do this.I have tried UIView animation but it's very fast.ALso how do i pass angel of rotation?
  2. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    you can control the animation block duration with setAnimationDuration:

    [UIView setAnimationDuration:kSpeedInSecondsOfAnimation];
    use CGAffineTransformMakeRotation to rotate your image object. it rotates in radians, so i've included a macro that will allow you to enter a degree.

    #define kDegreesToRadians(x) (M_PI * (x) / 180)
    CGAffineTransform transform = CGAffineTransformMakeRotation(kDegreesToRadians([I]angel[/I]));
    yourView.transform = transform;

Share This Page