2

Possible Duplicate:
How to use CGAffineTransformMakeRotation?

I have an imageview that acts like a button, I am looking for a way to show the user that he clicked on it, I came up with this code that will rotate it a bit :

 float angle =  60.0;
[UIView animateWithDuration:0.5f animations:^{
    customimageView.transform = CGAffineTransformMakeRotation(angle);
}];

but its not doing the behavior I am looking fpr. Anyone know how can I make the imagekinda zoom in ( or enlarge/ blowup ) to maybe 1.5 its size on its click? what kind of animation is relevant here? feel free to share behaviors you guys thought was cool in this situation.

Thanks.

As a side note, how can I make it just rotate full circle? I tried passing in 360 but its not doing it??

Community
  • 1
  • 1
Kalamantina
  • 303
  • 4
  • 10

3 Answers3

2

You can always CGAffineTransformConcat your rotation with a scaling transformation, made with CGAffineTransformMakeScale.

If you're interested in another button pressed effect, I needed something cool, too, and settled on a "throb" animation as follows:

BOOL keepThrobbing = NO;

-(void)buttonThrob:(CGFloat)inset {

    UIViewAnimationOptions opts = UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionAllowUserInteraction;

    [UIView animateWithDuration:0.2 delay:0.0 options:opts animations:^{
        self.button.frame = CGRectInset(self.button.frame, inset, inset);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.2 delay:0.0 options:opts animations:^{
            self.button.frame = CGRectInset(self.button.frame, -inset, -inset);
        } completion:^(BOOL finished) {
            if (finished && keepThrobbing) {
                [self buttonThrob:inset];
            }
        }];
    }];
}

Call it like this:

keepThrobbing = YES;
[self buttonThrob:10.0];  // expand/shrink by 10px in x and y
danh
  • 62,181
  • 10
  • 95
  • 136
0

Use CGAffineTransformMakeScale to change the scale.

CustomimageView.transform = CGAffineTransformMakeScale(1.5,1.5);

rdelmar
  • 103,982
  • 12
  • 207
  • 218
0

You can combine two affine transforms with CGAffineTransformConcat:

[customimageView setTransform:CGAffineTransformConcat(CGAffineTransformMakeScale(1.5, 1.5), CGAffineTransformMakeRotation(angle))];
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • thanks for noticing my duplicate post, i deleted it. not sure how that happened. i intended a minor edit. – danh Dec 20 '12 at 03:04