Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ruandao/d6148fa8f6f00b0a98b6 to your computer and use it in GitHub Desktop.

Select an option

Save ruandao/d6148fa8f6f00b0a98b6 to your computer and use it in GitHub Desktop.
UIScrollView+zoomToCenterWithScaleAnimated
//
// 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
//
// 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