# Objective C: rotating UIImage view then rotate in opposite direction

**URL:** <https://forum.kirupa.com/t/objective-c-rotating-uiimage-view-then-rotate-in-opposite-direction/311826>\
**Category:** programming\
**Created:** [July 17, 2010, 12:12pm UTC](https://forum.kirupa.com/t/objective-c-rotating-uiimage-view-then-rotate-in-opposite-direction/311826 "2010-07-17T12:12:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![damonlee3](https://avatars.discourse-cdn.com/v4/letter/d/ecd19e/32.png) [@damonlee3](https://forum.kirupa.com/u/damonlee3)\
**Post date:** [July 17, 2010, 12:12pm UTC](https://forum.kirupa.com/t/objective-c-rotating-uiimage-view-then-rotate-in-opposite-direction/311826/1 "2010-07-17T12:12:21Z")

</div>

Hello,

I’m new to objective c. My code has a scrolling back ground and in the fore ground is a spinning wheel.

I can scroll the back ground and rotate the wheel UIImage view just fine.

I’m having an issue with making the wheel rotate in the opposite direction when my background begins to scroll in the opposite direction.

Here’s my code:

```auto
  - (void) animateBG:(NSTimer *)animBGTimer {
    	
    	
    	scrollingBG.center = CGPointMake(scrollingBG.center.x, scrollingBG.center.y + scrollingBGMovement.y);
    
    	
    	wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / 20.0f);
    	
    	if (scrollingBG.center.y > 1220 || scrollingBG.center.y < -770 )
    		scrollingBGMovement.y = -scrollingBGMovement.y;
    		
    	if (scrollingBG.center.y > 1220){
    		wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / -20.0f);
    	}
    }

```

I’ve tried putting the line

```auto
wheel.transform = CGAffineTransformRotate(wheel.transform, M_PI / -20.0f);

```

right under my first “if” statement, but no go.

Any ideas?

Thank you  
Michael
