Created
June 22, 2014 15:13
-
-
Save ruandao/d6148fa8f6f00b0a98b6 to your computer and use it in GitHub Desktop.
UIScrollView+zoomToCenterWithScaleAnimated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIScrollView+zoomToCenterWithScale.h | |
| // locationme | |
| // | |
| // Created by 金燕赖 on 14-6-22. | |
| // Copyright (c) 2014年 ljy. All rights reserved. | |
| // | |
| #import <UIKit/UIKit.h> | |
| @interface UIScrollView (zoomToCenterWithScaleAnimated) | |
| - (void)zoomToCenter:(CGPoint)center withScale:(CGFloat)scale animated:(BOOL)animated; | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIScrollView+zoomToCenterWithScale.m | |
| // locationme | |
| // | |
| // Created by 金燕赖 on 14-6-22. | |
| // Copyright (c) 2014年 ljy. All rights reserved. | |
| // | |
| #import "UIScrollView+zoomToCenterWithScaleAnimated.h" | |
| @implementation UIScrollView (zoomToCenterWithScale) | |
| - (void)zoomToCenter:(CGPoint)center withScale:(CGFloat)scale animated:(BOOL)animated | |
| { | |
| CGRect rect; | |
| rect.size.width = self.frame.size.width / scale; | |
| rect.size.height = self.frame.size.height / scale; | |
| rect.origin.x = center.x - (rect.size.width / 2); | |
| rect.origin.y = center.y - (rect.size.height / 2); | |
| [self zoomToRect:rect animated:animated]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment