1, Transform
Just write following codes to scale (also called zoom in/out, or transform) your view:
float scaleX = xxx, scaleY = xxx;
CGAffineTransform transform = CGAffineTransformMakeScale(scaleX, scaleY];
yourView.transform = transform;
After scaled, you can set scaleX, and scaleY to scale to original size.
2, Animation
- (void) transformYourView()
{
float scaleX = xxx, scaleY = xxx;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.15]; //The default value is 0.2
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationFinshed:finsihed:context:)];
CGAffineTransform transform = CGAffineTransformMakeScale(scaleX, scaleY];
yourView.transform = transform;
[UIView commitAnimations];
}
- (void) animationFinshed:(NSString *) animationID finished:(NSNumber *)finished context:(void *)context
{
//To here, animation is finshed
}
3, Handle touch tap event;
You must customize UIView, and handle event.
//UICView.h
@interface UICView : UIView
@end
//UICView.m
@implementation UICView
//Handle touches began event
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
printf("members count=%i\r\n", touches.count);
for (UITouch *touch in touches)
{
printf("tap count = %i\r\n", touch.tapCount); //for dragging event, touch.tapCount is 0
}
[self touchesBegin:touches withEvent:event]; //You must invoke this interface, otherwise, application may can't handle event correctly.
}
@end
阅读(1254) | 评论(0) | 转发(0) |