how to rotate uiimageview at certain angle?

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

  1. rahulvyas macrumors newbie

    Joined:
    May 6, 2009
    #1
    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

    Darkroom

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

    Code:
    [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.

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

Share This Page