├── Example.png ├── Example ├── Classes │ ├── BDDRViewController.h │ ├── BDDRAppDelegate.h │ ├── BDDRAppDelegate.m │ └── BDDRViewController.m ├── Resources │ ├── Default-568h@2x.png │ └── BDDRScrollViewAdditions-Info.plist ├── Other Sources │ ├── main.m │ ├── BDDRScrollViewAdditions-Prefix.pch │ └── Storyboard.storyboard ├── BDDRScrollViewAdditions.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── BDDRScrollViewAdditions.xccheckout │ └── project.pbxproj └── Vendor │ ├── JRSwizzle.h │ ├── BDDROneFingerZoomGestureRecognizer.h │ ├── JRSwizzle.m │ └── BDDROneFingerZoomGestureRecognizer.m ├── .gitmodules ├── BDDRScrollViewAdditions.podspec ├── LICENSE ├── README.md └── BDDRScrollViewAdditions ├── UIScrollView+BDDRScrollViewAdditions.h └── UIScrollView+BDDRScrollViewAdditions.m /Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bddckr/BDDRScrollViewAdditions/HEAD/Example.png -------------------------------------------------------------------------------- /Example/Classes/BDDRViewController.h: -------------------------------------------------------------------------------- 1 | @interface BDDRViewController : UITableViewController 2 | 3 | @end 4 | -------------------------------------------------------------------------------- /Example/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bddckr/BDDRScrollViewAdditions/HEAD/Example/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /Example/Classes/BDDRAppDelegate.h: -------------------------------------------------------------------------------- 1 | @interface BDDRAppDelegate : UIResponder 2 | 3 | @property (strong, nonatomic) UIWindow *window; 4 | 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Other Sources/main.m: -------------------------------------------------------------------------------- 1 | #import "BDDRAppDelegate.h" 2 | 3 | int main(int argc, char *argv[]) { 4 | @autoreleasepool { 5 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([BDDRAppDelegate class])); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Example/Classes/BDDRAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "BDDRAppDelegate.h" 2 | 3 | @implementation BDDRAppDelegate 4 | 5 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 6 | return YES; 7 | } 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /Example/BDDRScrollViewAdditions.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Other Sources/BDDRScrollViewAdditions-Prefix.pch: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #ifndef __IPHONE_5_0 4 | #warning "This project uses features only available in iOS SDK 5.0 and later." 5 | #endif 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | #endif 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "BDDRScrollViewAdditions/Submodules/BDDROneFingerZoomGestureRecognizer"] 2 | path = BDDRScrollViewAdditions/Submodules/BDDROneFingerZoomGestureRecognizer 3 | url = https://github.com/bddckr/BDDROneFingerZoomGestureRecognizer.git 4 | [submodule "BDDRScrollViewAdditions/Submodules/JRSwizzle"] 5 | path = BDDRScrollViewAdditions/Submodules/JRSwizzle 6 | url = https://github.com/rentzsch/jrswizzle.git 7 | -------------------------------------------------------------------------------- /Example/Vendor/JRSwizzle.h: -------------------------------------------------------------------------------- 1 | // JRSwizzle.h semver:1.0 2 | // Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com 3 | // Some rights reserved: http://opensource.org/licenses/MIT 4 | // https://github.com/rentzsch/jrswizzle 5 | 6 | #import 7 | 8 | @interface NSObject (JRSwizzle) 9 | 10 | + (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_; 11 | + (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /BDDRScrollViewAdditions.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'BDDRScrollViewAdditions' 3 | s.version = '1.1.1' 4 | s.summary = 'UIScrollView category to center content, enable additional zoom gestures and add getters for animated properties.' 5 | s.homepage = 'https://github.com/bddckr/BDDRScrollViewAdditions' 6 | s.screenshots = 'https://github.com/bddckr/BDDRScrollViewAdditions/raw/master/Example.png' 7 | s.license = 'MIT' 8 | s.author = { 'Christopher - Marcel Böddecker' => 'bddckr@icloud.com' } 9 | s.source = { :git => 'https://github.com/bddckr/BDDRScrollViewAdditions.git', :tag => s.version.to_s } 10 | s.platform = :ios, '5.0' 11 | s.source_files = 'BDDRScrollViewAdditions' 12 | s.frameworks = 'QuartzCore' 13 | s.requires_arc = true 14 | s.dependency 'BDDROneFingerZoomGestureRecognizer', '~> 1.0' 15 | s.dependency 'JRSwizzle', '~> 1.0' 16 | end 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Christopher - Marcel Böddecker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Example/Resources/BDDRScrollViewAdditions-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.bddckr.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Storyboard 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Example/BDDRScrollViewAdditions.xcodeproj/project.xcworkspace/xcshareddata/BDDRScrollViewAdditions.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 01907003-8BDB-43C9-987C-0FFC2CE84BF2 9 | IDESourceControlProjectName 10 | BDDRScrollViewAdditions 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 747D7F26-F94D-4C20-BFAE-13156C87C8DC 14 | https://github.com/bddckr/BDDRScrollViewAdditions.git 15 | 16 | IDESourceControlProjectPath 17 | BDDRScrollViewAdditions.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 747D7F26-F94D-4C20-BFAE-13156C87C8DC 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/bddckr/BDDRScrollViewAdditions.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 747D7F26-F94D-4C20-BFAE-13156C87C8DC 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 747D7F26-F94D-4C20-BFAE-13156C87C8DC 36 | IDESourceControlWCCName 37 | BDDRScrollViewAdditions 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BDDRScrollViewAdditions 2 | [![The MIT License (MIT)](https://go-shields.herokuapp.com/license-MIT-blue.png)][MIT] 3 | [![Platform](https://cocoapod-badges.herokuapp.com/p/BDDRScrollViewAdditions/badge.png)][CocoaDocs] 4 | [![Version](https://cocoapod-badges.herokuapp.com/v/BDDRScrollViewAdditions/badge.png)][CocoaDocs] 5 | 6 | ## Description 7 | 8 | `UIScrollView` category to center content, enable additional zoom gestures and add getters for animated properties. 9 | 10 | This category adds properties to enable and configure: 11 | 12 | + Centering the content view, even when zooming out and having the `UIScrollView` bouncing. This also works for the view returned by `-viewForZoomingInScrollView:` of the `UIScrollViewDelegate` when zooming. 13 | 14 | + Double-tapping to zoom in, two-finger-tapping to zoom out and one-finger-zooming ([see BDDROneFingerZoomGestureRecognizer](https://github.com/bddckr/BDDROneFingerZoomGestureRecognizer)). Properties to access the gesture recognizers are provided. 15 | 16 | Additionally, this category adds `zoomScale`, `contentOffset` and `contentSize` getters that return correct values when an animation is running on the `UIScrollView`. These new properties are not KVO compliant but can be polled repeatedly. 17 | This is especially useful if you use an `UIScrollView` in your OpenGL View to scroll/zoom content: In your game loop you just poll the values to position and scale your rendered content. 18 | 19 | For more info see the [header]. 20 | 21 | Example 22 | 23 | ## Installation 24 | 25 | Simply add the files in the `UIScrollView+BDDRScrollViewAdditions.h` and `UIScrollView+BDDRScrollViewAdditions.m` to your project or add `BDDRScrollViewAdditions` to your Podfile if you're using CocoaPods. Alternatively use the configured submodules. 26 | 27 | To run the example project clone the repo and run `pod install` in the Example folder. 28 | 29 | ## Documentation 30 | 31 | Everything is documented in the [header file][header]. A rendered version is available on [CocoaDocs]. 32 | 33 | ## Reasons for Existence 34 | 35 | + Centering the content view is not done by default. 36 | 37 | + By default there is no support for double-tap-zoom-in, two-finger-zoom-out or one-finger-zoom gestures. 38 | 39 | + `UIScrollView` defines `zoomScale`, `contentOffset` and `contentSize` but these properties don't always return the correct values when `UIScrollView` is animating, for example when `zoomBouncing` is `YES`. 40 | 41 | ## Contact 42 | 43 | Follow [@bddckr](https://twitter.com/bddckr) on Twitter. 44 | 45 | ## Copyright and License 46 | 47 | Copyright (c) 2013-2014 Christopher - Marcel Böddecker 48 | Licensed under [The MIT License (MIT)][MIT]. 49 | 50 | [MIT]: http://choosealicense.com/licenses/mit 51 | [CocoaDocs]: http://cocoadocs.org/docsets/BDDRScrollViewAdditions 52 | [header]: https://github.com/bddckr/BDDRScrollViewAdditions/blob/master/BDDRScrollViewAdditions/UIScrollView+BDDRScrollViewAdditions.h 53 | -------------------------------------------------------------------------------- /Example/Classes/BDDRViewController.m: -------------------------------------------------------------------------------- 1 | #import "BDDRViewController.h" 2 | #import "UIScrollView+BDDRScrollViewAdditions.h" 3 | 4 | typedef NS_ENUM(NSUInteger, BDDRScrollViewFeature) { 5 | BDDRScrollViewFeatureCentering, 6 | BDDRScrollViewFeatureDoubleTapZoomIn, 7 | BDDRScrollViewFeatureDoubleTapZoomToMinimum, 8 | BDDRScrollViewFeatureTwoFingerZoomOut, 9 | BDDRScrollViewFeatureOneFingerZoom 10 | }; 11 | 12 | 13 | @interface BDDRViewController () 14 | 15 | @property (nonatomic, weak) IBOutlet UIScrollView *scrollView; 16 | @property (nonatomic, strong) UIView *zoomView; 17 | @property (nonatomic, assign) BOOL scrollViewIsSetUpCompletly; 18 | 19 | @end 20 | 21 | 22 | @implementation BDDRViewController 23 | 24 | #pragma mark - Managing the View 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | self.scrollView.bddr_centersContent = YES; 30 | self.scrollView.bddr_doubleTapZoomInEnabled = YES; 31 | self.scrollView.bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale = YES; 32 | self.scrollView.bddr_twoFingerZoomOutEnabled = YES; 33 | self.scrollView.bddr_oneFingerZoomEnabled = YES; 34 | 35 | self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor]; 36 | self.scrollView.delegate = self; 37 | self.scrollView.minimumZoomScale = 0.5f; 38 | self.scrollView.maximumZoomScale = 2.0f; 39 | 40 | NSUInteger numberOfCellsInHorizontalDirection = 10; 41 | NSUInteger numberOfCellsInVerticalDirection = 10; 42 | CGSize viewSize = self.scrollView.bounds.size; 43 | CGSize cellViewSize = (CGSize){viewSize.width / numberOfCellsInHorizontalDirection, viewSize.height / numberOfCellsInVerticalDirection}; 44 | 45 | self.zoomView = [[UIView alloc] initWithFrame:(CGRect){CGPointZero, self.scrollView.bounds.size}]; 46 | [self.scrollView addSubview:self.zoomView]; 47 | self.scrollView.contentSize = viewSize; 48 | 49 | for (NSUInteger x = 0; x < 10; x++) 50 | for (NSUInteger y = 0; y < 10; y++) { 51 | UIView *view = [[UIView alloc] initWithFrame:(CGRect){x * cellViewSize.width, y * cellViewSize.height, cellViewSize}]; 52 | view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255) / 255.0f 53 | green:arc4random_uniform(255) / 255.0f 54 | blue:arc4random_uniform(255) / 255.0f 55 | alpha:1.0f]; 56 | [self.zoomView addSubview:view]; 57 | } 58 | } 59 | 60 | - (void)viewDidLayoutSubviews { 61 | [super viewDidLayoutSubviews]; 62 | if (self.scrollViewIsSetUpCompletly) return; 63 | 64 | self.scrollView.zoomScale = self.scrollView.minimumZoomScale; 65 | self.scrollViewIsSetUpCompletly = YES; 66 | } 67 | 68 | #pragma mark - UIScrollViewDelegate Methods 69 | 70 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { 71 | if (scrollView != self.scrollView) return nil; 72 | return self.zoomView; 73 | } 74 | 75 | #pragma mark - UITableViewDelegate Methods 76 | 77 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 78 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 79 | BOOL featureOn; 80 | 81 | if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { 82 | cell.accessoryType = UITableViewCellAccessoryNone; 83 | featureOn = NO; 84 | } else { 85 | cell.accessoryType = UITableViewCellAccessoryCheckmark; 86 | featureOn = YES; 87 | } 88 | 89 | if (indexPath.row == BDDRScrollViewFeatureDoubleTapZoomIn) { 90 | UITableViewCell *doubleTapZoomToMinimumCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:BDDRScrollViewFeatureDoubleTapZoomToMinimum 91 | inSection:indexPath.section]]; 92 | doubleTapZoomToMinimumCell.textLabel.enabled = featureOn; 93 | doubleTapZoomToMinimumCell.userInteractionEnabled = featureOn; 94 | } 95 | 96 | switch (indexPath.row) { 97 | case BDDRScrollViewFeatureCentering: 98 | self.scrollView.bddr_centersContent = featureOn; 99 | break; 100 | case BDDRScrollViewFeatureDoubleTapZoomIn: 101 | self.scrollView.bddr_doubleTapZoomInEnabled = featureOn; 102 | break; 103 | case BDDRScrollViewFeatureDoubleTapZoomToMinimum: 104 | self.scrollView.bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale = featureOn; 105 | break; 106 | case BDDRScrollViewFeatureTwoFingerZoomOut: 107 | self.scrollView.bddr_twoFingerZoomOutEnabled = featureOn; 108 | break; 109 | case BDDRScrollViewFeatureOneFingerZoom: 110 | self.scrollView.bddr_oneFingerZoomEnabled = featureOn; 111 | break; 112 | default: 113 | break; 114 | } 115 | 116 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /Example/Vendor/BDDROneFingerZoomGestureRecognizer.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | /** 5 | * `UIGestureRecognizer` subclass to enable one-finger-zoom gestures. 6 | * 7 | * `BDDROneFingerZoomGestureRecognizer` is a concrete subclass of `UIGestureRecognizer` that looks for long-press gestures 8 | * followed by a move with one finger to calculate a scale factor. When the user moves the finger towards the bottom screen edge, 9 | * the conventional meaning is zoom-out; when the user moves the finger towards the top screen edge, the conventional meaning is zoom-in. 10 | * 11 | * One-finger-zoom gestures are continuous. The gesture begins (`UIGestureRecognizerStateBegan`) when one finger taps the specified 12 | * amount of times (`numberOfTapsRequired`), has been pressed for the specified period (`minimumPressDuration`) while not moving beyond the 13 | * allowable range of movement (`allowableMovement`), and then moves. The gesture changes (`UIGestureRecognizerStateChanged`) whenever the finger 14 | * moves, and it ends (`UIGestureRecognizerStateEnded`) when the finger is lifted. 15 | */ 16 | @interface BDDROneFingerZoomGestureRecognizer : UIGestureRecognizer 17 | 18 | /** 19 | * The number of full taps required before the long-press gesture after which the gesture is recognized. 20 | * 21 | * The default value is `1`. 22 | */ 23 | @property (nonatomic, assign) NSUInteger numberOfTapsRequired; 24 | 25 | /** 26 | * Time in seconds the finger must be held down for the gesture to be recognized. 27 | * 28 | * The default value is `0`. 29 | * 30 | * @see allowableMovement 31 | */ 32 | @property (nonatomic, assign) NSTimeInterval minimumPressDuration; 33 | 34 | /** 35 | * A floating-point value that specifies the maximum movement on screen allowed before the gesture fails. 36 | * 37 | * Once recognized (after `minimumPressDuration`) there is no limit on finger movement for the remainder of the touch tracking. 38 | * The default value is `10`. 39 | * 40 | * @see minimumPressDuration 41 | */ 42 | @property (nonatomic, assign) CGFloat allowableMovement; 43 | 44 | /** 45 | * A floating-point value that specifies the maximum scale factor to apply to `scale`. 46 | * 47 | * This value specifies the scale factor used to calculate `scale` when the user moves the finger from one screen edge 48 | * to the other (vertically only). For all movement in between the screen edges the receiver uses linear interpolation between `1` and this value. 49 | * The default value is `1.5`. 50 | * 51 | * @see scale 52 | */ 53 | @property (nonatomic, assign) CGFloat scaleFactor; 54 | 55 | /** 56 | * A floating-point value that specifies the scale factor relative to the moved distance of the touch in screen coordinates. 57 | * 58 | * The scale value is an absolute value that varies over time. It is not the delta value from the last time that the scale was reported. 59 | * Apply the scale value to the state of the view when the gesture is first recognized (`UIGestureRecognizerStateBegan`) — do not 60 | * concatenate the value each time the handler is called. 61 | * The default value is `1`. 62 | * 63 | * @warning You should not change this value when the gesture changes (`UIGestureRecognizerStateChanged`). 64 | * 65 | * @see scaleFactor 66 | */ 67 | @property (nonatomic, assign) CGFloat scale; 68 | 69 | /** 70 | * A Boolean value that determines whether the receiver adjusts `scale` when the scaling exceeds `minimumScale` or `maximumScale`. 71 | * 72 | * The default value is `NO`. 73 | * 74 | * @warning You should not change this value when the gesture changes (`UIGestureRecognizerStateChanged`). 75 | * 76 | * @see minimumScale, maximumScale 77 | */ 78 | @property (nonatomic, assign) BOOL bouncesScale; 79 | 80 | /** 81 | * A floating-point value that specifies the minimum scale factor that can be applied to `scale`. 82 | * 83 | * This is only used when `bouncesScale` is `YES`. 84 | * The default value is `1`. 85 | * 86 | * @warning You should not change this value when the gesture changes (`UIGestureRecognizerStateChanged`). 87 | * 88 | * @see bouncesScale, maximumScale 89 | */ 90 | @property (nonatomic, assign) CGFloat minimumScale; 91 | 92 | /** 93 | * A floating-point value that specifies the maximum scale factor that can be applied to `scale`. 94 | * 95 | * This is only used when `bouncesScale` is `YES`. 96 | * The default value is `1`. 97 | * 98 | * @warning You should not change this value when the gesture changes (`UIGestureRecognizerStateChanged`). 99 | * 100 | * @see bouncesScale, minimumScale 101 | */ 102 | @property (nonatomic, assign) CGFloat maximumScale; 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /Example/Vendor/JRSwizzle.m: -------------------------------------------------------------------------------- 1 | // JRSwizzle.m semver:1.0 2 | // Copyright (c) 2007-2011 Jonathan 'Wolf' Rentzsch: http://rentzsch.com 3 | // Some rights reserved: http://opensource.org/licenses/MIT 4 | // https://github.com/rentzsch/jrswizzle 5 | 6 | #import "JRSwizzle.h" 7 | 8 | #if TARGET_OS_IPHONE 9 | #import 10 | #import 11 | #else 12 | #import 13 | #endif 14 | 15 | #define SetNSErrorFor(FUNC, ERROR_VAR, FORMAT,...) \ 16 | if (ERROR_VAR) { \ 17 | NSString *errStr = [NSString stringWithFormat:@"%s: " FORMAT,FUNC,##__VA_ARGS__]; \ 18 | *ERROR_VAR = [NSError errorWithDomain:@"NSCocoaErrorDomain" \ 19 | code:-1 \ 20 | userInfo:[NSDictionary dictionaryWithObject:errStr forKey:NSLocalizedDescriptionKey]]; \ 21 | } 22 | #define SetNSError(ERROR_VAR, FORMAT,...) SetNSErrorFor(__func__, ERROR_VAR, FORMAT, ##__VA_ARGS__) 23 | 24 | #if OBJC_API_VERSION >= 2 25 | #define GetClass(obj) object_getClass(obj) 26 | #else 27 | #define GetClass(obj) (obj ? obj->isa : Nil) 28 | #endif 29 | 30 | @implementation NSObject (JRSwizzle) 31 | 32 | + (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)error_ { 33 | #if OBJC_API_VERSION >= 2 34 | Method origMethod = class_getInstanceMethod(self, origSel_); 35 | if (!origMethod) { 36 | #if TARGET_OS_IPHONE 37 | SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self class]); 38 | #else 39 | SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]); 40 | #endif 41 | return NO; 42 | } 43 | 44 | Method altMethod = class_getInstanceMethod(self, altSel_); 45 | if (!altMethod) { 46 | #if TARGET_OS_IPHONE 47 | SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self class]); 48 | #else 49 | SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]); 50 | #endif 51 | return NO; 52 | } 53 | 54 | class_addMethod(self, 55 | origSel_, 56 | class_getMethodImplementation(self, origSel_), 57 | method_getTypeEncoding(origMethod)); 58 | class_addMethod(self, 59 | altSel_, 60 | class_getMethodImplementation(self, altSel_), 61 | method_getTypeEncoding(altMethod)); 62 | 63 | method_exchangeImplementations(class_getInstanceMethod(self, origSel_), class_getInstanceMethod(self, altSel_)); 64 | return YES; 65 | #else 66 | // Scan for non-inherited methods. 67 | Method directOriginalMethod = NULL, directAlternateMethod = NULL; 68 | 69 | void *iterator = NULL; 70 | struct objc_method_list *mlist = class_nextMethodList(self, &iterator); 71 | while (mlist) { 72 | int method_index = 0; 73 | for (; method_index < mlist->method_count; method_index++) { 74 | if (mlist->method_list[method_index].method_name == origSel_) { 75 | assert(!directOriginalMethod); 76 | directOriginalMethod = &mlist->method_list[method_index]; 77 | } 78 | if (mlist->method_list[method_index].method_name == altSel_) { 79 | assert(!directAlternateMethod); 80 | directAlternateMethod = &mlist->method_list[method_index]; 81 | } 82 | } 83 | mlist = class_nextMethodList(self, &iterator); 84 | } 85 | 86 | // If either method is inherited, copy it up to the target class to make it non-inherited. 87 | if (!directOriginalMethod || !directAlternateMethod) { 88 | Method inheritedOriginalMethod = NULL, inheritedAlternateMethod = NULL; 89 | if (!directOriginalMethod) { 90 | inheritedOriginalMethod = class_getInstanceMethod(self, origSel_); 91 | if (!inheritedOriginalMethod) { 92 | SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]); 93 | return NO; 94 | } 95 | } 96 | if (!directAlternateMethod) { 97 | inheritedAlternateMethod = class_getInstanceMethod(self, altSel_); 98 | if (!inheritedAlternateMethod) { 99 | SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]); 100 | return NO; 101 | } 102 | } 103 | 104 | int hoisted_method_count = !directOriginalMethod && !directAlternateMethod ? 2 : 1; 105 | struct objc_method_list *hoisted_method_list = malloc(sizeof(struct objc_method_list) + (sizeof(struct objc_method)*(hoisted_method_count-1))); 106 | hoisted_method_list->obsolete = NULL; // soothe valgrind - apparently ObjC runtime accesses this value and it shows as uninitialized in valgrind 107 | hoisted_method_list->method_count = hoisted_method_count; 108 | Method hoisted_method = hoisted_method_list->method_list; 109 | 110 | if (!directOriginalMethod) { 111 | bcopy(inheritedOriginalMethod, hoisted_method, sizeof(struct objc_method)); 112 | directOriginalMethod = hoisted_method++; 113 | } 114 | if (!directAlternateMethod) { 115 | bcopy(inheritedAlternateMethod, hoisted_method, sizeof(struct objc_method)); 116 | directAlternateMethod = hoisted_method; 117 | } 118 | class_addMethods(self, hoisted_method_list); 119 | } 120 | 121 | // Swizzle. 122 | IMP temp = directOriginalMethod->method_imp; 123 | directOriginalMethod->method_imp = directAlternateMethod->method_imp; 124 | directAlternateMethod->method_imp = temp; 125 | 126 | return YES; 127 | #endif 128 | } 129 | 130 | + (BOOL)jr_swizzleClassMethod:(SEL)origSel_ withClassMethod:(SEL)altSel_ error:(NSError**)error_ { 131 | return [GetClass((id)self) jr_swizzleMethod:origSel_ withMethod:altSel_ error:error_]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /BDDRScrollViewAdditions/UIScrollView+BDDRScrollViewAdditions.h: -------------------------------------------------------------------------------- 1 | @class BDDROneFingerZoomGestureRecognizer; 2 | 3 | 4 | /** 5 | * `UIScrollView` category to center content, enable additional zoom gestures and add getters for animated properties. 6 | */ 7 | @interface UIScrollView (BDDRScrollViewAdditions) 8 | 9 | /** 10 | * A Boolean value that determines whether the receiver's content view is centered. 11 | * 12 | * Setting the value of this property to `YES` centers the receiver's content view and setting it to `NO` stops the centering. 13 | * The default value is `NO`. 14 | */ 15 | @property (nonatomic, assign) BOOL bddr_centersContent; 16 | 17 | /** 18 | * A Boolean value that determines whether zooming in by double-tapping is enabled. 19 | * 20 | * If the value of this property is `YES`, the scroll view zooms in the content when the user taps two times with one finger: 21 | * @code self.zoomScale *= self.bddr_zoomScaleStepFactor; @endcode 22 | * The default value is `NO`. 23 | * 24 | * @warning When zooming is disabled, the scroll view does not enable zooming via this property. 25 | * See the documentation of `UIScrollView` on how to enable zooming. 26 | * 27 | * @see bddr_zoomScaleStepFactor, bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale, bddr_doubleTapZoomInGestureRecognizer 28 | */ 29 | @property (nonatomic, assign) BOOL bddr_doubleTapZoomInEnabled; 30 | 31 | /** 32 | * A Boolean value that determines whether zooming to `minimumZoomScale` when double-tapping at `maximumZoomScale` is enabled. 33 | * 34 | * If the value of this property is `YES`, the scroll view zooms to `minimumZoomScale` when the user taps two times with one finger 35 | * and `zoomScale` is equal to `maximumZoomScale`. 36 | * The default value is `YES`. 37 | * 38 | * @see minimumZoomScale, maximumZoomScale, zoomScale 39 | */ 40 | @property (nonatomic, assign) BOOL bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale; 41 | 42 | /** 43 | * The underlying gesture recognizer for double-tap-zoom-in gestures. (read-only) 44 | * 45 | * Your application accesses this property when it wants to more precisely control which double-tap-zoom-in gestures are 46 | * recognized by the scroll view. 47 | * This property is `nil` if `bddr_doubleTapZoomInEnabled` is `NO`. 48 | * 49 | * @see bddr_doubleTapZoomInEnabled 50 | */ 51 | @property (nonatomic, strong, readonly) UITapGestureRecognizer *bddr_doubleTapZoomInGestureRecognizer; 52 | 53 | /** 54 | * A Boolean value that determines whether zooming out by two-finger-tapping is enabled. 55 | * 56 | * If the value of this property is `YES`, the scroll view zooms out the content when the user taps with two fingers: 57 | * @code self.zoomScale /= self.bddr_zoomScaleStepFactor; @endcode 58 | * The default value is `NO`. 59 | * 60 | * @warning When zooming is disabled, the scroll view does not enable zooming via this property. 61 | * See the documentation of `UIScrollView` on how to enable zooming. 62 | * 63 | * @see bddr_zoomScaleStepFactor, bddr_twoFingerZoomOutGestureRecognizer 64 | */ 65 | @property (nonatomic, assign) BOOL bddr_twoFingerZoomOutEnabled; 66 | 67 | /** 68 | * The underlying gesture recognizer for two-finger-zoom-out gestures. (read-only) 69 | * 70 | * Your application accesses this property when it wants to more precisely control which two-finger-zoom-out gestures are 71 | * recognized by the scroll view. 72 | * This property is `nil` if `bddr_twoFingerZoomOutEnabled` is `NO`. 73 | * 74 | * @see bddr_twoFingerZoomOutEnabled 75 | */ 76 | @property (nonatomic, strong, readonly) UITapGestureRecognizer *bddr_twoFingerZoomOutGestureRecognizer; 77 | 78 | /** 79 | * A Boolean value that determines whether zooming with one finger is enabled. 80 | * 81 | * If the value of this property is `YES`, the scroll view zooms the content when the user double taps and then moves the finger. 82 | * This uses `bddr_zoomScaleStepFactor` for the zooming and respects `bouncesZoom`. 83 | * The default value is `NO`. 84 | * 85 | * @warning When zooming is disabled, the scroll view does not enable zooming via this property. 86 | * See the documentation of `UIScrollView` on how to enable zooming. 87 | * 88 | * @see bddr_zoomScaleStepFactor, bddr_oneFingerZoomGestureRecognizer, bouncesZoom 89 | */ 90 | @property (nonatomic, assign) BOOL bddr_oneFingerZoomEnabled; 91 | 92 | /** 93 | * The underlying gesture recognizer for one-finger-zoom gestures. (read-only) 94 | * 95 | * Your application accesses this property when it wants to more precisely control which one-finger-zoom gestures are 96 | * recognized by the scroll view. 97 | * This property is `nil` if `bddr_oneFingerZoomEnabled` is `NO`. 98 | * 99 | * @see bddr_oneFingerZoomEnabled 100 | */ 101 | @property (nonatomic, strong, readonly) BDDROneFingerZoomGestureRecognizer *bddr_oneFingerZoomGestureRecognizer; 102 | 103 | /** 104 | * A floating-point value that specifies the scale factor applied to the scroll view's `zoomScale` when double-tap-zoom-in, 105 | * two-finger-zoom-out or one-finger-zoom gestures occur. 106 | * 107 | * This value determines by how much the receiver's `zoomScale` is changed. 108 | * The default value is `1.5`. 109 | * 110 | * @see bddr_doubleTapZoomInEnabled, bddr_twoFingerZoomOutEnabled, bddr_oneFingerZoomEnabled 111 | */ 112 | @property (nonatomic, assign) CGFloat bddr_zoomScaleStepFactor; 113 | 114 | /** 115 | * The visible rectangle, which describes the content view's location and size in the receiver's coordinate system. 116 | */ 117 | @property (nonatomic, assign, readonly) CGRect bddr_visibleRect; 118 | 119 | /** 120 | * Calculates a rectangle for a specified zoom scale and center point in the receiver's coordinate system. 121 | * 122 | * @param zoomScale The zoom scale of the receiver for the calculation of the returned rectangle. 123 | * @param center The center of the returned rectangle. 124 | * 125 | * @return A rectangle defining an area of the content view, centered at `center` and scaled by `zoomScale`. 126 | */ 127 | - (CGRect)bddr_zoomRectForZoomScale:(CGFloat)zoomScale center:(CGPoint)center; 128 | 129 | /** 130 | * The receiver's `contentOffset` property, during animations. (read-only) 131 | * 132 | * `contentOffset` returns the wrong value if the receiver is animating, for example when `zoomBouncing` is `YES`. 133 | * 134 | * @see contentOffset 135 | */ 136 | @property (nonatomic, assign, readonly) CGPoint bddr_presentationLayerContentOffset; 137 | 138 | /** 139 | * The receiver's `contentSize` property, during animations. (read-only) 140 | * 141 | * `contentSize` returns the wrong value if the receiver is animating, for example when `zoomBouncing` is `YES`. 142 | * 143 | * @see contentSize 144 | */ 145 | @property (nonatomic, assign, readonly) CGSize bddr_presentationLayerContentSize; 146 | 147 | /** 148 | * The receiver's `zoomScale` property, during animations. (read-only) 149 | * 150 | * `zoomScale` returns the wrong value if the receiver is animating, for example when `zoomBouncing` is `YES`. 151 | * 152 | * @see zoomScale 153 | */ 154 | @property (nonatomic, assign, readonly) CGFloat bddr_presentationLayerZoomScale; 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /Example/Vendor/BDDROneFingerZoomGestureRecognizer.m: -------------------------------------------------------------------------------- 1 | #import "BDDROneFingerZoomGestureRecognizer.h" 2 | #import 3 | 4 | @interface BDDROneFingerZoomGestureRecognizer () 5 | 6 | @property (nonatomic, weak) NSTimer *timer; 7 | @property (nonatomic, assign) CGPoint initialLocationOnScreen; 8 | @property (nonatomic, assign) CGFloat initialScale; 9 | @property (nonatomic, assign) BOOL pressedLongEnough; 10 | 11 | @end 12 | 13 | 14 | @implementation BDDROneFingerZoomGestureRecognizer 15 | 16 | #pragma mark - Initialization 17 | 18 | - (instancetype)initWithTarget:(id)target action:(SEL)action { 19 | self = [super initWithTarget:target action:action]; 20 | if (!self) return nil; 21 | 22 | _numberOfTapsRequired = 1; 23 | _allowableMovement = 10.0f; 24 | _scaleFactor = 1.5f; 25 | _scale = 1.0f; 26 | _minimumScale = 1.0f; 27 | _maximumScale = 1.0f; 28 | 29 | return self; 30 | } 31 | 32 | #pragma mark - Private Utility Methods 33 | 34 | - (CGFloat)screenLocationYOfTouch:(UITouch *)touch { 35 | return [touch.window convertPoint:[touch locationInView:nil] toWindow:nil].y; 36 | } 37 | 38 | - (CGFloat)zoomRubberBandScaleForZoomScale:(CGFloat)scale minimumZoomScale:(CGFloat)minimumZoomScale maximumZoomScale:(CGFloat)maximumZoomScale { 39 | if (scale <= maximumZoomScale) { 40 | if (scale >= minimumZoomScale) 41 | return scale; 42 | else 43 | scale = minimumZoomScale / (2.0f - (scale / minimumZoomScale)); 44 | } else 45 | scale = maximumZoomScale * (2.0f - (maximumZoomScale / scale)); 46 | 47 | return scale; 48 | } 49 | 50 | - (CGFloat)zoomScaleForRubberBandScale:(CGFloat)zoomRubberBandScale minimumZoomScale:(CGFloat)minimumZoomScale maximumZoomScale:(CGFloat)maximumZoomScale { 51 | if (zoomRubberBandScale <= maximumZoomScale) { 52 | if (zoomRubberBandScale >= minimumZoomScale) 53 | return zoomRubberBandScale; 54 | else 55 | zoomRubberBandScale = minimumZoomScale * (2.0f - (minimumZoomScale / zoomRubberBandScale)); 56 | } else 57 | zoomRubberBandScale = -(powf(maximumZoomScale, 2.0f) / (zoomRubberBandScale - (2.0f * maximumZoomScale))); 58 | 59 | return zoomRubberBandScale; 60 | } 61 | 62 | #pragma mark - Getting the Location of a Gesture 63 | 64 | - (CGPoint)locationInView:(UIView *)view { 65 | CGSize screenSize = [UIScreen mainScreen].bounds.size; 66 | CGPoint locationOnScreen = (CGPoint){screenSize.width / 2.0f, screenSize.height / 2.0f}; 67 | return [view convertPoint:[self.view.window convertPoint:locationOnScreen fromWindow:nil] fromView:self.view.window]; 68 | } 69 | 70 | #pragma mark - Gesture Recognition 71 | 72 | - (void)handleTimer:(NSTimer *)timer { 73 | self.pressedLongEnough = YES; 74 | self.timer = nil; 75 | } 76 | 77 | - (void)reset { 78 | [super reset]; 79 | 80 | [self.timer invalidate]; 81 | self.timer = nil; 82 | self.initialLocationOnScreen = CGPointZero; 83 | self.initialScale = 1.0f; 84 | self.pressedLongEnough = NO; 85 | } 86 | 87 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 88 | [super touchesBegan:touches withEvent:event]; 89 | 90 | UITouch *touch = [touches anyObject]; 91 | if (self.state == UIGestureRecognizerStatePossible && [touches count] == 1 && touch.tapCount == self.numberOfTapsRequired + 1) { 92 | NSTimer *timer = [NSTimer timerWithTimeInterval:self.minimumPressDuration target:self selector:@selector(handleTimer:) userInfo:nil repeats:NO]; 93 | [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; 94 | 95 | self.timer = timer; 96 | self.initialLocationOnScreen = [touch.window convertPoint:[touch locationInView:nil] toWindow:nil]; 97 | } else if (self.state != UIGestureRecognizerStateFailed) 98 | self.state = UIGestureRecognizerStateCancelled; 99 | } 100 | 101 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 102 | [super touchesMoved:touches withEvent:event]; 103 | if (self.state != UIGestureRecognizerStatePossible && 104 | self.state != UIGestureRecognizerStateBegan && 105 | self.state != UIGestureRecognizerStateChanged) return; 106 | 107 | UITouch *touch = [touches anyObject]; 108 | if (touch.tapCount != self.numberOfTapsRequired + 1) return; 109 | 110 | CGPoint currentLocationOnScreen = [touch.window convertPoint:[touch locationInView:nil] toWindow:nil]; 111 | if (self.state == UIGestureRecognizerStatePossible) { 112 | if (self.pressedLongEnough) 113 | self.state = UIGestureRecognizerStateBegan; 114 | else { 115 | CGFloat movedDistance = sqrtf(powf(currentLocationOnScreen.x - self.initialLocationOnScreen.x, 2.0f) + 116 | powf(currentLocationOnScreen.y - self.initialLocationOnScreen.y, 2.0f)); 117 | if (movedDistance > self.allowableMovement) 118 | self.state = UIGestureRecognizerStateFailed; 119 | } 120 | } else if (self.state == UIGestureRecognizerStateBegan) { 121 | self.initialScale = self.scale; 122 | self.state = UIGestureRecognizerStateChanged; 123 | } else if (self.state == UIGestureRecognizerStateChanged) { 124 | CGFloat movedDistance = self.initialLocationOnScreen.y - currentLocationOnScreen.y; 125 | CGFloat movedPercent = ABS(movedDistance) / [UIScreen mainScreen].bounds.size.height; 126 | CGFloat scalePercent = 1.0f + (self.scaleFactor - 1.0f) * movedPercent; 127 | CGFloat newScale = self.initialScale * (movedDistance > 0.0f ? scalePercent : 1.0f / scalePercent); 128 | 129 | if (self.bouncesScale) 130 | self.scale = [self zoomRubberBandScaleForZoomScale:newScale minimumZoomScale:self.minimumScale maximumZoomScale:self.maximumScale]; 131 | else 132 | self.scale = newScale; 133 | } 134 | } 135 | 136 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 137 | [super touchesEnded:touches withEvent:event]; 138 | 139 | if (self.state == UIGestureRecognizerStateBegan) 140 | self.state = UIGestureRecognizerStateCancelled; 141 | else if (self.state == UIGestureRecognizerStateChanged) 142 | self.state = UIGestureRecognizerStateEnded; 143 | else 144 | self.state = UIGestureRecognizerStateFailed; 145 | } 146 | 147 | - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { 148 | [super touchesCancelled:touches withEvent:event]; 149 | 150 | if (self.state == UIGestureRecognizerStateBegan || self.state == UIGestureRecognizerStateChanged) 151 | self.state = UIGestureRecognizerStateCancelled; 152 | else 153 | self.state = UIGestureRecognizerStateFailed; 154 | } 155 | 156 | #pragma mark - Interaction with other UIGestureRecognizers 157 | 158 | - (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer { 159 | if ([preventedGestureRecognizer isKindOfClass:[UIPinchGestureRecognizer class]]) 160 | return NO; 161 | else 162 | return [super canPreventGestureRecognizer:preventedGestureRecognizer]; 163 | } 164 | 165 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 166 | - (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { 167 | if ([otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) 168 | return YES; 169 | else { 170 | if ([[self class] instancesRespondToSelector:_cmd]) 171 | return [super shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer]; 172 | else 173 | return NO; 174 | } 175 | } 176 | #endif 177 | 178 | #pragma mark - Getters and Setters 179 | 180 | - (void)setScaleFactor:(CGFloat)scaleFactor { 181 | _scaleFactor = MAX(1.0f, scaleFactor); 182 | } 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /Example/Other Sources/Storyboard.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /BDDRScrollViewAdditions/UIScrollView+BDDRScrollViewAdditions.m: -------------------------------------------------------------------------------- 1 | #import "UIScrollView+BDDRScrollViewAdditions.h" 2 | #import "BDDROneFingerZoomGestureRecognizer.h" 3 | #import "JRSwizzle.h" 4 | #import 5 | #import 6 | 7 | @implementation UIScrollView (BDDRScrollViewAdditions) 8 | 9 | #pragma mark - Method Swizzling 10 | 11 | + (void)load { 12 | NSError *error; 13 | if (![self jr_swizzleMethod:@selector(setContentOffset:) withMethod:@selector(bddr_setContentOffset:) error:&error]) 14 | NSLog(@"%@", [error localizedDescription]); 15 | if (![self jr_swizzleMethod:@selector(contentInset) withMethod:@selector(bddr_contentInset) error:&error]) 16 | NSLog(@"%@", [error localizedDescription]); 17 | if (![self jr_swizzleMethod:@selector(setContentInset:) withMethod:@selector(bddr_setContentInset:) error:&error]) 18 | NSLog(@"%@", [error localizedDescription]); 19 | } 20 | 21 | #pragma mark - Private Utility Methods 22 | 23 | - (CGRect)bddr_zoomRectForZoomScale:(CGFloat)zoomScale locationOfGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer { 24 | UIView *zoomView = [self.delegate respondsToSelector:@selector(viewForZoomingInScrollView:)] ? [self.delegate viewForZoomingInScrollView:self] : self; 25 | CGPoint location = [gestureRecognizer locationInView:zoomView]; 26 | return [self bddr_zoomRectForZoomScale:zoomScale center:location]; 27 | } 28 | 29 | #pragma mark - Content Centering 30 | 31 | - (void)bddr_centerContent { 32 | CGSize contentSize = self.contentSize; 33 | CGSize boundsSize = self.bounds.size; 34 | UIEdgeInsets contentInset = self.contentInset; 35 | CGFloat horizontalInset = 0.0f; 36 | CGFloat verticalInset = 0.0f; 37 | 38 | if (self.bddr_centersContent) { 39 | if (contentSize.width < boundsSize.width) 40 | horizontalInset = (boundsSize.width - contentSize.width) / 2.0f; 41 | if (contentSize.height < boundsSize.height) 42 | verticalInset = (boundsSize.height - contentSize.height) / 2.0f; 43 | } 44 | 45 | contentInset.top += verticalInset; 46 | contentInset.bottom += verticalInset; 47 | contentInset.left += horizontalInset; 48 | contentInset.right += horizontalInset; 49 | 50 | [self bddr_setContentInset:contentInset]; 51 | } 52 | 53 | #pragma mark - Double Tap Zoom In 54 | 55 | - (void)bddr_addOrRemoveDoubleTapZoomInGestureRecognizer { 56 | UITapGestureRecognizer *doubleTapZoomInGestureRecognizer; 57 | 58 | if (self.bddr_doubleTapZoomInEnabled) { 59 | doubleTapZoomInGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bddr_handleDoubleTapZoomInGestureRecognizer:)]; 60 | doubleTapZoomInGestureRecognizer.numberOfTapsRequired = 2; 61 | [self addGestureRecognizer:doubleTapZoomInGestureRecognizer]; 62 | } else 63 | [self removeGestureRecognizer:self.bddr_doubleTapZoomInGestureRecognizer]; 64 | 65 | self.bddr_doubleTapZoomInGestureRecognizer = doubleTapZoomInGestureRecognizer; 66 | } 67 | 68 | - (void)bddr_handleDoubleTapZoomInGestureRecognizer:(UITapGestureRecognizer *)doubleTapZoomInGestureRecognizer { 69 | if (doubleTapZoomInGestureRecognizer.state != UIGestureRecognizerStateEnded) return; 70 | 71 | if (self.zoomScale == self.maximumZoomScale && self.bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale) { 72 | [self setZoomScale:self.minimumZoomScale animated:YES]; 73 | return; 74 | } 75 | 76 | CGFloat newZoomScale = self.zoomScale * self.bddr_zoomScaleStepFactor; 77 | CGRect zoomRect = [self bddr_zoomRectForZoomScale:newZoomScale locationOfGestureRecognizer:doubleTapZoomInGestureRecognizer]; 78 | [self zoomToRect:zoomRect animated:YES]; 79 | } 80 | 81 | #pragma mark - Two Finger Zoom Out 82 | 83 | - (void)bddr_addOrRemoveTwoFingerZoomOutGestureRecognizer { 84 | UITapGestureRecognizer *twoFingerZoomOutGestureRecognizer; 85 | 86 | if (self.bddr_twoFingerZoomOutEnabled) { 87 | twoFingerZoomOutGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(bddr_handleTwoFingerZoomOutGestureRecognizer:)]; 88 | twoFingerZoomOutGestureRecognizer.numberOfTouchesRequired = 2; 89 | [self addGestureRecognizer:twoFingerZoomOutGestureRecognizer]; 90 | } else 91 | [self removeGestureRecognizer:self.bddr_twoFingerZoomOutGestureRecognizer]; 92 | 93 | self.bddr_twoFingerZoomOutGestureRecognizer = twoFingerZoomOutGestureRecognizer; 94 | } 95 | 96 | - (void)bddr_handleTwoFingerZoomOutGestureRecognizer:(UITapGestureRecognizer *)twoFingerZoomOutGestureRecognizer { 97 | if (twoFingerZoomOutGestureRecognizer.state != UIGestureRecognizerStateEnded) return; 98 | 99 | CGFloat newZoomScale = self.zoomScale / self.bddr_zoomScaleStepFactor; 100 | CGRect zoomRect = [self bddr_zoomRectForZoomScale:newZoomScale locationOfGestureRecognizer:twoFingerZoomOutGestureRecognizer]; 101 | [self zoomToRect:zoomRect animated:YES]; 102 | } 103 | 104 | #pragma mark - One Finger Zoom 105 | 106 | - (void)bddr_addOrRemoveOneFingerZoomGestureRecognizer { 107 | BDDROneFingerZoomGestureRecognizer *oneFingerZoomGestureRecognizer; 108 | 109 | if (self.bddr_oneFingerZoomEnabled) { 110 | oneFingerZoomGestureRecognizer = [[BDDROneFingerZoomGestureRecognizer alloc] initWithTarget:self action:@selector(bddr_handleOneFingerZoomGestureRecognizer:)]; 111 | oneFingerZoomGestureRecognizer.bouncesScale = YES; 112 | [self addGestureRecognizer:oneFingerZoomGestureRecognizer]; 113 | } else 114 | [self removeGestureRecognizer:self.bddr_oneFingerZoomGestureRecognizer]; 115 | 116 | self.bddr_oneFingerZoomGestureRecognizer = oneFingerZoomGestureRecognizer; 117 | } 118 | 119 | - (void)bddr_handleOneFingerZoomGestureRecognizer:(BDDROneFingerZoomGestureRecognizer *)oneFingerZoomGestureRecognizer { 120 | switch (oneFingerZoomGestureRecognizer.state) { 121 | case UIGestureRecognizerStateBegan: 122 | oneFingerZoomGestureRecognizer.scaleFactor = self.maximumZoomScale / self.minimumZoomScale; 123 | oneFingerZoomGestureRecognizer.scale = self.zoomScale; 124 | oneFingerZoomGestureRecognizer.minimumScale = self.minimumZoomScale; 125 | oneFingerZoomGestureRecognizer.maximumScale = self.maximumZoomScale; 126 | 127 | if (self.bouncesZoom) { 128 | self.minimumZoomScale /= 2.0f; 129 | self.maximumZoomScale *= 2.0f; 130 | } 131 | 132 | if ([self.delegate respondsToSelector:@selector(scrollViewWillBeginZooming:withView:)]) 133 | [self.delegate scrollViewWillBeginZooming:self withView:[self.delegate viewForZoomingInScrollView:self]]; 134 | break; 135 | case UIGestureRecognizerStateChanged: 136 | self.zoomScale = oneFingerZoomGestureRecognizer.scale; 137 | break; 138 | case UIGestureRecognizerStateEnded: 139 | case UIGestureRecognizerStateCancelled: 140 | if ([self.delegate respondsToSelector:@selector(scrollViewDidEndZooming:withView:atScale:)]) 141 | [self.delegate scrollViewDidEndZooming:self withView:[self.delegate viewForZoomingInScrollView:self] atScale:oneFingerZoomGestureRecognizer.scale]; 142 | 143 | if (self.bouncesZoom) { 144 | self.minimumZoomScale *= 2.0f; 145 | self.maximumZoomScale /= 2.0f; 146 | 147 | if (self.zoomScale < self.minimumZoomScale) 148 | [self setZoomScale:self.minimumZoomScale animated:YES]; 149 | else if (self.zoomScale > self.maximumZoomScale) 150 | [self setZoomScale:self.maximumZoomScale animated:YES]; 151 | } 152 | break; 153 | default: 154 | break; 155 | } 156 | } 157 | 158 | #pragma mark - Overridden Getters and Setters 159 | 160 | - (void)bddr_setContentOffset:(CGPoint)contentOffset { 161 | [self bddr_setContentOffset:contentOffset]; 162 | [self bddr_centerContent]; 163 | } 164 | 165 | - (UIEdgeInsets)bddr_contentInset { 166 | return [objc_getAssociatedObject(self, @selector(bddr_contentInset)) UIEdgeInsetsValue]; 167 | } 168 | 169 | - (void)bddr_setContentInset:(UIEdgeInsets)contentInset { 170 | objc_setAssociatedObject(self, @selector(bddr_contentInset), [NSValue valueWithUIEdgeInsets:contentInset], OBJC_ASSOCIATION_RETAIN_NONATOMIC); 171 | [self bddr_centerContent]; 172 | } 173 | 174 | #pragma mark - Calculated Rectangles 175 | 176 | - (CGRect)bddr_visibleRect { 177 | UIView *zoomView = [self.delegate respondsToSelector:@selector(viewForZoomingInScrollView:)] ? [self.delegate viewForZoomingInScrollView:self] : self; 178 | return [self convertRect:self.bounds toView:zoomView]; 179 | } 180 | 181 | - (CGRect)bddr_zoomRectForZoomScale:(CGFloat)zoomScale center:(CGPoint)center { 182 | CGSize boundsSize = self.bounds.size; 183 | CGRect zoomRect; 184 | 185 | zoomRect.size.width = boundsSize.width / zoomScale; 186 | zoomRect.size.height = boundsSize.height / zoomScale; 187 | zoomRect.origin.x = center.x - (zoomRect.size.width / 2.0f); 188 | zoomRect.origin.y = center.y - (zoomRect.size.height / 2.0f); 189 | 190 | return zoomRect; 191 | } 192 | 193 | #pragma mark - Getters of animated Properties 194 | 195 | - (CGPoint)bddr_presentationLayerContentOffset { 196 | CALayer *presentationLayer = self.layer.presentationLayer; 197 | return presentationLayer.bounds.origin; 198 | } 199 | 200 | - (CGSize)bddr_presentationLayerContentSize { 201 | if ([self.delegate respondsToSelector:@selector(viewForZoomingInScrollView:)]) { 202 | UIView *zoomView = [self.delegate viewForZoomingInScrollView:self]; 203 | CALayer *zoomPresentationLayer = zoomView.layer.presentationLayer; 204 | 205 | return zoomPresentationLayer.frame.size; 206 | } else 207 | return self.contentSize; 208 | } 209 | 210 | - (CGFloat)bddr_presentationLayerZoomScale { 211 | if ([self.delegate respondsToSelector:@selector(viewForZoomingInScrollView:)]) { 212 | UIView *zoomView = [self.delegate viewForZoomingInScrollView:self]; 213 | CALayer *zoomPresentationLayer = zoomView.layer.presentationLayer; 214 | 215 | return zoomPresentationLayer.transform.m11; 216 | } else 217 | return self.zoomScale; 218 | } 219 | 220 | #pragma mark - Getters and Setters 221 | 222 | - (BOOL)bddr_centersContent { 223 | return [objc_getAssociatedObject(self, @selector(bddr_centersContent)) boolValue]; 224 | } 225 | 226 | - (void)setBddr_centersContent:(BOOL)centersContent { 227 | objc_setAssociatedObject(self, @selector(bddr_centersContent), @(centersContent), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 228 | [self bddr_centerContent]; 229 | } 230 | 231 | - (BOOL)bddr_doubleTapZoomInEnabled { 232 | return [objc_getAssociatedObject(self, @selector(bddr_doubleTapZoomInEnabled)) boolValue]; 233 | } 234 | 235 | - (void)setBddr_doubleTapZoomInEnabled:(BOOL)doubleTapZoomInEnabled { 236 | objc_setAssociatedObject(self, @selector(bddr_doubleTapZoomInEnabled), @(doubleTapZoomInEnabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 237 | [self bddr_addOrRemoveDoubleTapZoomInGestureRecognizer]; 238 | } 239 | 240 | - (BOOL)bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale { 241 | NSNumber *doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScaleNumber = objc_getAssociatedObject(self, @selector(bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale)); 242 | 243 | if (!doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScaleNumber) { 244 | doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScaleNumber = @(YES); 245 | objc_setAssociatedObject(self, @selector(bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale), doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScaleNumber, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 246 | } 247 | 248 | return [doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScaleNumber boolValue]; 249 | } 250 | 251 | - (void)setBddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale:(BOOL)bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale { 252 | objc_setAssociatedObject(self, @selector(bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale), @(bddr_doubleTapZoomsToMinimumZoomScaleWhenAtMaximumZoomScale), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 253 | } 254 | 255 | - (UITapGestureRecognizer *)bddr_doubleTapZoomInGestureRecognizer { 256 | return objc_getAssociatedObject(self, @selector(bddr_doubleTapZoomInGestureRecognizer)); 257 | } 258 | 259 | - (void)setBddr_doubleTapZoomInGestureRecognizer:(UITapGestureRecognizer *)doubleTapZoomInGestureRecognizer { 260 | objc_setAssociatedObject(self, @selector(bddr_doubleTapZoomInGestureRecognizer), doubleTapZoomInGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 261 | } 262 | 263 | - (BOOL)bddr_twoFingerZoomOutEnabled { 264 | return [objc_getAssociatedObject(self, @selector(bddr_twoFingerZoomOutEnabled)) boolValue]; 265 | } 266 | 267 | - (void)setBddr_twoFingerZoomOutEnabled:(BOOL)twoFingerZoomOutEnabled { 268 | objc_setAssociatedObject(self, @selector(bddr_twoFingerZoomOutEnabled), @(twoFingerZoomOutEnabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 269 | [self bddr_addOrRemoveTwoFingerZoomOutGestureRecognizer]; 270 | } 271 | 272 | - (UITapGestureRecognizer *)bddr_twoFingerZoomOutGestureRecognizer { 273 | return objc_getAssociatedObject(self, @selector(bddr_twoFingerZoomOutGestureRecognizer)); 274 | } 275 | 276 | - (void)setBddr_twoFingerZoomOutGestureRecognizer:(UITapGestureRecognizer *)twoFingerZoomOutGestureRecognizer { 277 | objc_setAssociatedObject(self, @selector(bddr_twoFingerZoomOutGestureRecognizer), twoFingerZoomOutGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 278 | } 279 | 280 | - (BOOL)bddr_oneFingerZoomEnabled { 281 | return [objc_getAssociatedObject(self, @selector(bddr_oneFingerZoomEnabled)) boolValue]; 282 | } 283 | 284 | - (void)setBddr_oneFingerZoomEnabled:(BOOL)oneFingerZoomEnabled { 285 | objc_setAssociatedObject(self, @selector(bddr_oneFingerZoomEnabled), @(oneFingerZoomEnabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 286 | [self bddr_addOrRemoveOneFingerZoomGestureRecognizer]; 287 | } 288 | 289 | - (BDDROneFingerZoomGestureRecognizer *)bddr_oneFingerZoomGestureRecognizer { 290 | return objc_getAssociatedObject(self, @selector(bddr_oneFingerZoomGestureRecognizer)); 291 | } 292 | 293 | - (void)setBddr_oneFingerZoomGestureRecognizer:(BDDROneFingerZoomGestureRecognizer *)oneFingerZoomGestureRecognizer { 294 | objc_setAssociatedObject(self, @selector(bddr_oneFingerZoomGestureRecognizer), oneFingerZoomGestureRecognizer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 295 | } 296 | 297 | - (CGFloat)bddr_zoomScaleStepFactor { 298 | NSNumber *zoomScaleStepFactorNumber = objc_getAssociatedObject(self, @selector(bddr_zoomScaleStepFactor)); 299 | 300 | if (!zoomScaleStepFactorNumber) { 301 | zoomScaleStepFactorNumber = @(1.5f); 302 | objc_setAssociatedObject(self, @selector(bddr_zoomScaleStepFactor), zoomScaleStepFactorNumber, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 303 | } 304 | 305 | return [zoomScaleStepFactorNumber floatValue]; 306 | } 307 | 308 | - (void)setBddr_zoomScaleStepFactor:(CGFloat)zoomScaleStepFactor { 309 | zoomScaleStepFactor = MAX(1.0f, zoomScaleStepFactor); 310 | objc_setAssociatedObject(self, @selector(bddr_zoomScaleStepFactor), @(zoomScaleStepFactor), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 311 | } 312 | 313 | @end 314 | -------------------------------------------------------------------------------- /Example/BDDRScrollViewAdditions.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EE42C6B217B0464E004BA34D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE42C6B117B0464E004BA34D /* UIKit.framework */; }; 11 | EE42C6B417B0464E004BA34D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE42C6B317B0464E004BA34D /* Foundation.framework */; }; 12 | EE42C6B617B0464E004BA34D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE42C6B517B0464E004BA34D /* CoreGraphics.framework */; }; 13 | EE42C6F317B04FF6004BA34D /* BDDRAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EE42C6EB17B04FF6004BA34D /* BDDRAppDelegate.m */; }; 14 | EE42C6F417B04FF6004BA34D /* BDDRViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE42C6ED17B04FF6004BA34D /* BDDRViewController.m */; }; 15 | EE42C6F517B04FF6004BA34D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = EE42C6F017B04FF6004BA34D /* main.m */; }; 16 | EE42C6FA17B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = EE42C6F917B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.m */; }; 17 | EE42C6FC17B0594C004BA34D /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE42C6FB17B0594C004BA34D /* Default-568h@2x.png */; }; 18 | EE42C6FE17B059A6004BA34D /* Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EE42C6FD17B059A6004BA34D /* Storyboard.storyboard */; }; 19 | EE890D3817C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = EE890D3517C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.m */; }; 20 | EE890D3917C26B39004A563F /* JRSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = EE890D3717C26B39004A563F /* JRSwizzle.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | EE42C6AE17B0464E004BA34D /* BDDRScrollViewAdditions.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BDDRScrollViewAdditions.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | EE42C6B117B0464E004BA34D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 26 | EE42C6B317B0464E004BA34D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 27 | EE42C6B517B0464E004BA34D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 28 | EE42C6EA17B04FF6004BA34D /* BDDRAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDDRAppDelegate.h; sourceTree = ""; }; 29 | EE42C6EB17B04FF6004BA34D /* BDDRAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDDRAppDelegate.m; sourceTree = ""; }; 30 | EE42C6EC17B04FF6004BA34D /* BDDRViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDDRViewController.h; sourceTree = ""; }; 31 | EE42C6ED17B04FF6004BA34D /* BDDRViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BDDRViewController.m; sourceTree = ""; }; 32 | EE42C6EF17B04FF6004BA34D /* BDDRScrollViewAdditions-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BDDRScrollViewAdditions-Prefix.pch"; sourceTree = ""; }; 33 | EE42C6F017B04FF6004BA34D /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | EE42C6F217B04FF6004BA34D /* BDDRScrollViewAdditions-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "BDDRScrollViewAdditions-Info.plist"; sourceTree = ""; }; 35 | EE42C6F817B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScrollView+BDDRScrollViewAdditions.h"; sourceTree = ""; }; 36 | EE42C6F917B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScrollView+BDDRScrollViewAdditions.m"; sourceTree = ""; }; 37 | EE42C6FB17B0594C004BA34D /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 38 | EE42C6FD17B059A6004BA34D /* Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Storyboard.storyboard; sourceTree = ""; }; 39 | EE890D3417C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BDDROneFingerZoomGestureRecognizer.h; path = Vendor/BDDROneFingerZoomGestureRecognizer.h; sourceTree = SOURCE_ROOT; }; 40 | EE890D3517C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BDDROneFingerZoomGestureRecognizer.m; path = Vendor/BDDROneFingerZoomGestureRecognizer.m; sourceTree = SOURCE_ROOT; }; 41 | EE890D3617C26B39004A563F /* JRSwizzle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JRSwizzle.h; path = Vendor/JRSwizzle.h; sourceTree = SOURCE_ROOT; }; 42 | EE890D3717C26B39004A563F /* JRSwizzle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = JRSwizzle.m; path = Vendor/JRSwizzle.m; sourceTree = SOURCE_ROOT; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | EE42C6AB17B0464E004BA34D /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | EE42C6B217B0464E004BA34D /* UIKit.framework in Frameworks */, 51 | EE42C6B417B0464E004BA34D /* Foundation.framework in Frameworks */, 52 | EE42C6B617B0464E004BA34D /* CoreGraphics.framework in Frameworks */, 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | EE42C6A517B0464E004BA34D = { 60 | isa = PBXGroup; 61 | children = ( 62 | EE42C6E917B04FF6004BA34D /* Classes */, 63 | EE42C6F717B05016004BA34D /* Vendor */, 64 | EE42C6EE17B04FF6004BA34D /* Other Sources */, 65 | EE42C6F117B04FF6004BA34D /* Resources */, 66 | EE42C6B017B0464E004BA34D /* Frameworks */, 67 | EE42C6AF17B0464E004BA34D /* Products */, 68 | ); 69 | sourceTree = ""; 70 | }; 71 | EE42C6AF17B0464E004BA34D /* Products */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | EE42C6AE17B0464E004BA34D /* BDDRScrollViewAdditions.app */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | EE42C6B017B0464E004BA34D /* Frameworks */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | EE42C6B117B0464E004BA34D /* UIKit.framework */, 83 | EE42C6B317B0464E004BA34D /* Foundation.framework */, 84 | EE42C6B517B0464E004BA34D /* CoreGraphics.framework */, 85 | ); 86 | name = Frameworks; 87 | sourceTree = ""; 88 | }; 89 | EE42C6E917B04FF6004BA34D /* Classes */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | EE42C6EA17B04FF6004BA34D /* BDDRAppDelegate.h */, 93 | EE42C6EB17B04FF6004BA34D /* BDDRAppDelegate.m */, 94 | EE42C6EC17B04FF6004BA34D /* BDDRViewController.h */, 95 | EE42C6ED17B04FF6004BA34D /* BDDRViewController.m */, 96 | ); 97 | path = Classes; 98 | sourceTree = ""; 99 | }; 100 | EE42C6EE17B04FF6004BA34D /* Other Sources */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | EE42C6F017B04FF6004BA34D /* main.m */, 104 | EE42C6EF17B04FF6004BA34D /* BDDRScrollViewAdditions-Prefix.pch */, 105 | EE42C6FD17B059A6004BA34D /* Storyboard.storyboard */, 106 | ); 107 | path = "Other Sources"; 108 | sourceTree = ""; 109 | }; 110 | EE42C6F117B04FF6004BA34D /* Resources */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | EE42C6F217B04FF6004BA34D /* BDDRScrollViewAdditions-Info.plist */, 114 | EE42C6FB17B0594C004BA34D /* Default-568h@2x.png */, 115 | ); 116 | path = Resources; 117 | sourceTree = ""; 118 | }; 119 | EE42C6F717B05016004BA34D /* Vendor */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | EE42C6F817B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.h */, 123 | EE42C6F917B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.m */, 124 | EE890D3417C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.h */, 125 | EE890D3517C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.m */, 126 | EE890D3617C26B39004A563F /* JRSwizzle.h */, 127 | EE890D3717C26B39004A563F /* JRSwizzle.m */, 128 | ); 129 | name = Vendor; 130 | path = ../BDDRScrollViewAdditions; 131 | sourceTree = ""; 132 | }; 133 | /* End PBXGroup section */ 134 | 135 | /* Begin PBXNativeTarget section */ 136 | EE42C6AD17B0464E004BA34D /* BDDRScrollViewAdditions */ = { 137 | isa = PBXNativeTarget; 138 | buildConfigurationList = EE42C6D417B0464E004BA34D /* Build configuration list for PBXNativeTarget "BDDRScrollViewAdditions" */; 139 | buildPhases = ( 140 | EE42C6AA17B0464E004BA34D /* Sources */, 141 | EE42C6AB17B0464E004BA34D /* Frameworks */, 142 | EE42C6AC17B0464E004BA34D /* Resources */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = BDDRScrollViewAdditions; 149 | productName = BDDRScrollViewAdditionsExample; 150 | productReference = EE42C6AE17B0464E004BA34D /* BDDRScrollViewAdditions.app */; 151 | productType = "com.apple.product-type.application"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | EE42C6A617B0464E004BA34D /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | CLASSPREFIX = BDDR; 160 | LastUpgradeCheck = 0460; 161 | ORGANIZATIONNAME = "Christopher - Marcel Böddecker"; 162 | }; 163 | buildConfigurationList = EE42C6A917B0464E004BA34D /* Build configuration list for PBXProject "BDDRScrollViewAdditions" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = EE42C6A517B0464E004BA34D; 171 | productRefGroup = EE42C6AF17B0464E004BA34D /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | EE42C6AD17B0464E004BA34D /* BDDRScrollViewAdditions */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | EE42C6AC17B0464E004BA34D /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | EE42C6FC17B0594C004BA34D /* Default-568h@2x.png in Resources */, 186 | EE42C6FE17B059A6004BA34D /* Storyboard.storyboard in Resources */, 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | /* End PBXResourcesBuildPhase section */ 191 | 192 | /* Begin PBXSourcesBuildPhase section */ 193 | EE42C6AA17B0464E004BA34D /* Sources */ = { 194 | isa = PBXSourcesBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | EE42C6F317B04FF6004BA34D /* BDDRAppDelegate.m in Sources */, 198 | EE42C6F417B04FF6004BA34D /* BDDRViewController.m in Sources */, 199 | EE42C6F517B04FF6004BA34D /* main.m in Sources */, 200 | EE42C6FA17B05016004BA34D /* UIScrollView+BDDRScrollViewAdditions.m in Sources */, 201 | EE890D3817C26B39004A563F /* BDDROneFingerZoomGestureRecognizer.m in Sources */, 202 | EE890D3917C26B39004A563F /* JRSwizzle.m in Sources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXSourcesBuildPhase section */ 207 | 208 | /* Begin XCBuildConfiguration section */ 209 | EE42C6D217B0464E004BA34D /* Debug */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_OBJC_ARC = YES; 216 | CLANG_WARN_CONSTANT_CONVERSION = YES; 217 | CLANG_WARN_EMPTY_BODY = YES; 218 | CLANG_WARN_ENUM_CONVERSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 221 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 222 | COPY_PHASE_STRIP = NO; 223 | GCC_C_LANGUAGE_STANDARD = gnu99; 224 | GCC_DYNAMIC_NO_PIC = NO; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 233 | GCC_WARN_UNUSED_VARIABLE = YES; 234 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 235 | ONLY_ACTIVE_ARCH = YES; 236 | SDKROOT = iphoneos; 237 | TARGETED_DEVICE_FAMILY = "1,2"; 238 | }; 239 | name = Debug; 240 | }; 241 | EE42C6D317B0464E004BA34D /* Release */ = { 242 | isa = XCBuildConfiguration; 243 | buildSettings = { 244 | ALWAYS_SEARCH_USER_PATHS = NO; 245 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 246 | CLANG_CXX_LIBRARY = "libc++"; 247 | CLANG_ENABLE_OBJC_ARC = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INT_CONVERSION = YES; 252 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 253 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 254 | COPY_PHASE_STRIP = YES; 255 | GCC_C_LANGUAGE_STANDARD = gnu99; 256 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 260 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 261 | SDKROOT = iphoneos; 262 | TARGETED_DEVICE_FAMILY = "1,2"; 263 | VALIDATE_PRODUCT = YES; 264 | }; 265 | name = Release; 266 | }; 267 | EE42C6D517B0464E004BA34D /* Debug */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 271 | GCC_PREFIX_HEADER = "Other Sources/BDDRScrollViewAdditions-Prefix.pch"; 272 | INFOPLIST_FILE = "$(SRCROOT)/Resources/BDDRScrollViewAdditions-Info.plist"; 273 | PRODUCT_NAME = BDDRScrollViewAdditions; 274 | WRAPPER_EXTENSION = app; 275 | }; 276 | name = Debug; 277 | }; 278 | EE42C6D617B0464E004BA34D /* Release */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 282 | GCC_PREFIX_HEADER = "Other Sources/BDDRScrollViewAdditions-Prefix.pch"; 283 | INFOPLIST_FILE = "$(SRCROOT)/Resources/BDDRScrollViewAdditions-Info.plist"; 284 | PRODUCT_NAME = BDDRScrollViewAdditions; 285 | WRAPPER_EXTENSION = app; 286 | }; 287 | name = Release; 288 | }; 289 | /* End XCBuildConfiguration section */ 290 | 291 | /* Begin XCConfigurationList section */ 292 | EE42C6A917B0464E004BA34D /* Build configuration list for PBXProject "BDDRScrollViewAdditions" */ = { 293 | isa = XCConfigurationList; 294 | buildConfigurations = ( 295 | EE42C6D217B0464E004BA34D /* Debug */, 296 | EE42C6D317B0464E004BA34D /* Release */, 297 | ); 298 | defaultConfigurationIsVisible = 0; 299 | defaultConfigurationName = Release; 300 | }; 301 | EE42C6D417B0464E004BA34D /* Build configuration list for PBXNativeTarget "BDDRScrollViewAdditions" */ = { 302 | isa = XCConfigurationList; 303 | buildConfigurations = ( 304 | EE42C6D517B0464E004BA34D /* Debug */, 305 | EE42C6D617B0464E004BA34D /* Release */, 306 | ); 307 | defaultConfigurationIsVisible = 0; 308 | defaultConfigurationName = Release; 309 | }; 310 | /* End XCConfigurationList section */ 311 | }; 312 | rootObject = EE42C6A617B0464E004BA34D /* Project object */; 313 | } 314 | --------------------------------------------------------------------------------