├── .DS_Store ├── .gitignore ├── HYPanGestureRecognizer ├── HYPanGestureRecognizer.h ├── HYPanGestureRecognizer.m ├── HYSnapshotView.h └── HYSnapshotView.m ├── HYPanTableView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── HYPanTableViewDemo ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ └── LaunchScreen.xib ├── DetailViewController.h ├── DetailViewController.m ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── HYPanTableViewTests ├── HYPanTableViewTests.m └── Info.plist ├── LICENSE ├── README.md └── screenshot.gif /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanwhy/HYPanViewController/64a1b99a0d7836c1912a5dd32263f83063e87386/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /HYPanGestureRecognizer/HYPanGestureRecognizer.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015-1016 nathanwhy ( https://github.com/nathanwhy ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, 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, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | 24 | #import 25 | 26 | @class HYPanGestureRecognizer; 27 | 28 | typedef void(^HYHandler)(HYPanGestureRecognizer *panGesture, NSIndexPath *indexpath, BOOL isLeft); 29 | 30 | @interface HYPanGestureRecognizer : UIPanGestureRecognizer 31 | - (instancetype)initWithTabelView:(UITableView *)tableView Handler:(HYHandler) handler; 32 | 33 | @property (nonatomic, copy) HYHandler panHandler; 34 | @property (nonatomic, weak) UITableView *tableView; 35 | @property (nonatomic, strong) CATextLayer *leftLayer; 36 | @property (nonatomic, strong) CATextLayer *rightLayer; 37 | 38 | - (void)addLeftText:(NSString *)leftText rightText:(NSString *)rightText; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /HYPanGestureRecognizer/HYPanGestureRecognizer.m: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2015-1016 nathanwhy ( https://github.com/nathanwhy ) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, 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, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | // SOFTWARE. 22 | 23 | #import "HYPanGestureRecognizer.h" 24 | #import "HYSnapshotView.h" 25 | 26 | static CGFloat const kPanFontSize = 15.0f; 27 | 28 | static inline CGFloat angleWithOffsetX(CGFloat x, CGFloat viewWidth){ 29 | return (M_PI / 180.0 * (x / viewWidth) * 20); 30 | } 31 | 32 | @implementation HYPanGestureRecognizer 33 | 34 | - (instancetype)initWithTabelView:(UITableView *)tableView Handler:(HYHandler) handler 35 | { 36 | self = [self initWithTarget:self action:@selector(hy_handleAction:)]; 37 | if (!self) return nil; 38 | 39 | self.tableView = tableView; 40 | self.panHandler = handler; 41 | self.delaysTouchesBegan = YES; 42 | 43 | return self; 44 | } 45 | 46 | - (CATextLayer*)createLayerWithText:(NSString *)text{ 47 | CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:kPanFontSize] constrainedToSize:CGSizeMake(100, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping]; 48 | CATextLayer *layer = [CATextLayer layer]; 49 | layer.bounds = CGRectMake(0, 0, size.width, size.height); 50 | layer.font = (__bridge CFTypeRef)[UIFont systemFontOfSize:kPanFontSize].fontName; 51 | layer.fontSize = kPanFontSize; 52 | layer.foregroundColor = [UIColor redColor].CGColor; 53 | layer.string = text; 54 | return layer; 55 | } 56 | 57 | - (CATextLayer *)leftLayer{ 58 | if (_leftLayer == nil) { 59 | _leftLayer = [self createLayerWithText:@"leftText"]; 60 | } 61 | return _leftLayer; 62 | } 63 | 64 | - (CATextLayer *)rightLayer{ 65 | if (_rightLayer == nil) { 66 | _rightLayer = [self createLayerWithText:@"rightText"]; 67 | } 68 | return _rightLayer; 69 | } 70 | 71 | - (void)addLeftText:(NSString *)leftText rightText:(NSString *)rightText { 72 | _leftLayer = [self createLayerWithText:leftText]; 73 | _rightLayer = [self createLayerWithText:rightText]; 74 | } 75 | 76 | - (void)hy_handleAction:(UIPanGestureRecognizer *)gesture 77 | { 78 | CGPoint movePoint = [self translationInView:self.tableView]; 79 | CGPoint location = [self locationInView:self.tableView]; 80 | CGFloat viewWidth = self.tableView.frame.size.width; 81 | 82 | static NSIndexPath *sourceIndexPath = nil; 83 | static UIView *snapshot = nil; 84 | static BOOL isFirstTouch; 85 | 86 | switch (self.state) { 87 | case UIGestureRecognizerStateBegan:{ 88 | NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location]; 89 | if (indexPath == nil) return; 90 | UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 91 | 92 | snapshot = [HYSnapshotView customSnapshoFromView:cell]; 93 | 94 | CGFloat cellH = cell.frame.size.height; 95 | 96 | self.leftLayer.anchorPoint = CGPointMake(1, 0.5); 97 | self.leftLayer.position = CGPointMake(-10, cellH / 2); 98 | [snapshot.layer addSublayer:self.leftLayer]; 99 | 100 | 101 | self.rightLayer.anchorPoint = CGPointMake(0, 0.5); 102 | self.rightLayer.position = CGPointMake(viewWidth + 10, cellH / 2); 103 | [snapshot.layer addSublayer:self.rightLayer]; 104 | 105 | isFirstTouch = YES; 106 | sourceIndexPath = indexPath; 107 | snapshot.center = cell.center; 108 | snapshot.alpha = 0.0; 109 | [self.tableView addSubview:snapshot]; 110 | [UIView animateWithDuration:0.25 animations:^{ 111 | snapshot.alpha = 0.98; 112 | cell.alpha = 0.0; 113 | 114 | } completion:^(BOOL finished) { 115 | cell.hidden = YES; 116 | }]; 117 | 118 | } 119 | break; 120 | case UIGestureRecognizerStateChanged:{ 121 | 122 | CGAffineTransform transform = CGAffineTransformIdentity; 123 | transform = CGAffineTransformRotate(transform, angleWithOffsetX(movePoint.x, viewWidth)); 124 | transform = CGAffineTransformTranslate(transform, movePoint.x, 0); 125 | snapshot.transform = transform; 126 | 127 | } 128 | break; 129 | default: { // end 130 | UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:sourceIndexPath]; 131 | 132 | if (fabs(movePoint.x) > viewWidth*0.3) { 133 | typeof(self) __weak weakSelf = self; 134 | [UIView animateWithDuration:0.4 animations:^{ 135 | 136 | CGFloat offsetX = movePoint.x > 0? viewWidth: -viewWidth; 137 | CGAffineTransform transform = CGAffineTransformIdentity; 138 | offsetX *= 1.2f; 139 | transform = CGAffineTransformRotate(transform, angleWithOffsetX(offsetX, viewWidth)); 140 | transform = CGAffineTransformTranslate(transform, offsetX, 0); 141 | [snapshot setTransform:transform]; 142 | [snapshot setAlpha:1]; 143 | } completion:^(BOOL finished) { 144 | cell.alpha = 1.0; 145 | cell.hidden = NO; 146 | [snapshot removeFromSuperview]; 147 | 148 | if (weakSelf.panHandler) { 149 | weakSelf.panHandler(weakSelf, sourceIndexPath, movePoint.x < 0); 150 | } 151 | 152 | snapshot = nil; 153 | isFirstTouch = NO; 154 | sourceIndexPath = nil; 155 | }]; 156 | 157 | }else{ 158 | 159 | [UIView animateWithDuration:0.5 animations:^{ 160 | [snapshot setTransform:CGAffineTransformIdentity]; 161 | [snapshot setAlpha:1]; 162 | } completion:^(BOOL finished) { 163 | cell.alpha = 1.0; 164 | cell.hidden = NO; 165 | [snapshot removeFromSuperview]; 166 | snapshot = nil; 167 | isFirstTouch = NO; 168 | sourceIndexPath = nil; 169 | }]; 170 | } 171 | } 172 | break; 173 | } 174 | } 175 | 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /HYPanGestureRecognizer/HYSnapshotView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HYSnapshotView.h 3 | // HYPanTableView 4 | // 5 | // Created by why on 15/2/28. 6 | // Copyright (c) 2015年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HYSnapshotView : UIView 12 | 13 | + (UIView *)customSnapshoFromView:(UIView *)inputView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HYPanGestureRecognizer/HYSnapshotView.m: -------------------------------------------------------------------------------- 1 | // 2 | // HYSnapshotView.m 3 | // HYPanTableView 4 | // 5 | // Created by why on 15/2/28. 6 | // Copyright (c) 2015年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import "HYSnapshotView.h" 10 | 11 | @implementation HYSnapshotView 12 | 13 | + (UIView *)customSnapshoFromView:(UIView *)inputView 14 | { 15 | UIView *snapShot = [[UIView alloc] initWithFrame:inputView.frame]; 16 | UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, YES, 1); 17 | [inputView.layer renderInContext:UIGraphicsGetCurrentContext()]; 18 | UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 19 | UIGraphicsEndImageContext(); 20 | 21 | UIImageView *shot = [[UIImageView alloc]initWithImage:viewImage]; 22 | [snapShot addSubview:shot]; 23 | snapShot.layer.masksToBounds = NO; 24 | snapShot.layer.cornerRadius = 0.0; 25 | snapShot.layer.shadowOpacity = 0.4; 26 | 27 | return snapShot; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HYPanTableView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6B34EBDD1A39529F0005B663 /* HYPanTableViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B34EBDC1A39529F0005B663 /* HYPanTableViewTests.m */; }; 11 | 9607F4D71AA1A7BC00943169 /* HYSnapshotView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9607F4D61AA1A7BC00943169 /* HYSnapshotView.m */; }; 12 | 9607F4DD1AA1AFD800943169 /* HYPanGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 9607F4DC1AA1AFD800943169 /* HYPanGestureRecognizer.m */; }; 13 | D8AADA311A3C9479002C2EEA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D8AADA271A3C9479002C2EEA /* AppDelegate.m */; }; 14 | D8AADA321A3C9479002C2EEA /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8AADA281A3C9479002C2EEA /* LaunchScreen.xib */; }; 15 | D8AADA331A3C9479002C2EEA /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D8AADA2B1A3C9479002C2EEA /* DetailViewController.m */; }; 16 | D8AADA341A3C9479002C2EEA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8AADA2C1A3C9479002C2EEA /* Images.xcassets */; }; 17 | D8AADA361A3C9479002C2EEA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D8AADA2E1A3C9479002C2EEA /* main.m */; }; 18 | D8AADA371A3C9479002C2EEA /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D8AADA301A3C9479002C2EEA /* ViewController.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 6B34EBD71A39529F0005B663 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 6B34EBB51A39529E0005B663 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 6B34EBBC1A39529E0005B663; 27 | remoteInfo = HYPanTableView; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 6B34EBBD1A39529E0005B663 /* HYPanTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HYPanTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 6B34EBD61A39529F0005B663 /* HYPanTableViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HYPanTableViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 6B34EBDB1A39529F0005B663 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 6B34EBDC1A39529F0005B663 /* HYPanTableViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HYPanTableViewTests.m; sourceTree = ""; }; 36 | 9607F4D51AA1A7BC00943169 /* HYSnapshotView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYSnapshotView.h; sourceTree = ""; }; 37 | 9607F4D61AA1A7BC00943169 /* HYSnapshotView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYSnapshotView.m; sourceTree = ""; }; 38 | 9607F4DB1AA1AFD800943169 /* HYPanGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HYPanGestureRecognizer.h; sourceTree = ""; }; 39 | 9607F4DC1AA1AFD800943169 /* HYPanGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HYPanGestureRecognizer.m; sourceTree = ""; }; 40 | D8AADA261A3C9479002C2EEA /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 41 | D8AADA271A3C9479002C2EEA /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 42 | D8AADA291A3C9479002C2EEA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 43 | D8AADA2A1A3C9479002C2EEA /* DetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; 44 | D8AADA2B1A3C9479002C2EEA /* DetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = ""; }; 45 | D8AADA2C1A3C9479002C2EEA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 46 | D8AADA2D1A3C9479002C2EEA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | D8AADA2E1A3C9479002C2EEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | D8AADA2F1A3C9479002C2EEA /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 49 | D8AADA301A3C9479002C2EEA /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 6B34EBBA1A39529E0005B663 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | 6B34EBD31A39529F0005B663 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 6B34EBB41A39529E0005B663 = { 71 | isa = PBXGroup; 72 | children = ( 73 | D8AADA251A3C9479002C2EEA /* HYPanTableViewDemo */, 74 | 6B34EBD91A39529F0005B663 /* HYPanTableViewTests */, 75 | 6B34EBBE1A39529E0005B663 /* Products */, 76 | ); 77 | sourceTree = ""; 78 | }; 79 | 6B34EBBE1A39529E0005B663 /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 6B34EBBD1A39529E0005B663 /* HYPanTableView.app */, 83 | 6B34EBD61A39529F0005B663 /* HYPanTableViewTests.xctest */, 84 | ); 85 | name = Products; 86 | sourceTree = ""; 87 | }; 88 | 6B34EBD91A39529F0005B663 /* HYPanTableViewTests */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 6B34EBDC1A39529F0005B663 /* HYPanTableViewTests.m */, 92 | 6B34EBDA1A39529F0005B663 /* Supporting Files */, 93 | ); 94 | path = HYPanTableViewTests; 95 | sourceTree = ""; 96 | }; 97 | 6B34EBDA1A39529F0005B663 /* Supporting Files */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 6B34EBDB1A39529F0005B663 /* Info.plist */, 101 | ); 102 | name = "Supporting Files"; 103 | sourceTree = ""; 104 | }; 105 | D8AADA251A3C9479002C2EEA /* HYPanTableViewDemo */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | D8AADA381A3C948B002C2EEA /* HYPanGestureRecognizer */, 109 | D8AADA261A3C9479002C2EEA /* AppDelegate.h */, 110 | D8AADA271A3C9479002C2EEA /* AppDelegate.m */, 111 | D8AADA2F1A3C9479002C2EEA /* ViewController.h */, 112 | D8AADA301A3C9479002C2EEA /* ViewController.m */, 113 | D8AADA2A1A3C9479002C2EEA /* DetailViewController.h */, 114 | D8AADA2B1A3C9479002C2EEA /* DetailViewController.m */, 115 | D8AADA2C1A3C9479002C2EEA /* Images.xcassets */, 116 | D8AADA281A3C9479002C2EEA /* LaunchScreen.xib */, 117 | D8AADA2D1A3C9479002C2EEA /* Info.plist */, 118 | D8AADA2E1A3C9479002C2EEA /* main.m */, 119 | ); 120 | path = HYPanTableViewDemo; 121 | sourceTree = ""; 122 | }; 123 | D8AADA381A3C948B002C2EEA /* HYPanGestureRecognizer */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 9607F4D51AA1A7BC00943169 /* HYSnapshotView.h */, 127 | 9607F4D61AA1A7BC00943169 /* HYSnapshotView.m */, 128 | 9607F4DB1AA1AFD800943169 /* HYPanGestureRecognizer.h */, 129 | 9607F4DC1AA1AFD800943169 /* HYPanGestureRecognizer.m */, 130 | ); 131 | path = HYPanGestureRecognizer; 132 | sourceTree = SOURCE_ROOT; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | 6B34EBBC1A39529E0005B663 /* HYPanTableView */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = 6B34EBE01A39529F0005B663 /* Build configuration list for PBXNativeTarget "HYPanTableView" */; 140 | buildPhases = ( 141 | 6B34EBB91A39529E0005B663 /* Sources */, 142 | 6B34EBBA1A39529E0005B663 /* Frameworks */, 143 | 6B34EBBB1A39529E0005B663 /* Resources */, 144 | ); 145 | buildRules = ( 146 | ); 147 | dependencies = ( 148 | ); 149 | name = HYPanTableView; 150 | productName = HYPanTableView; 151 | productReference = 6B34EBBD1A39529E0005B663 /* HYPanTableView.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | 6B34EBD51A39529F0005B663 /* HYPanTableViewTests */ = { 155 | isa = PBXNativeTarget; 156 | buildConfigurationList = 6B34EBE31A39529F0005B663 /* Build configuration list for PBXNativeTarget "HYPanTableViewTests" */; 157 | buildPhases = ( 158 | 6B34EBD21A39529F0005B663 /* Sources */, 159 | 6B34EBD31A39529F0005B663 /* Frameworks */, 160 | 6B34EBD41A39529F0005B663 /* Resources */, 161 | ); 162 | buildRules = ( 163 | ); 164 | dependencies = ( 165 | 6B34EBD81A39529F0005B663 /* PBXTargetDependency */, 166 | ); 167 | name = HYPanTableViewTests; 168 | productName = HYPanTableViewTests; 169 | productReference = 6B34EBD61A39529F0005B663 /* HYPanTableViewTests.xctest */; 170 | productType = "com.apple.product-type.bundle.unit-test"; 171 | }; 172 | /* End PBXNativeTarget section */ 173 | 174 | /* Begin PBXProject section */ 175 | 6B34EBB51A39529E0005B663 /* Project object */ = { 176 | isa = PBXProject; 177 | attributes = { 178 | LastUpgradeCheck = 0630; 179 | ORGANIZATIONNAME = nathanwu; 180 | TargetAttributes = { 181 | 6B34EBBC1A39529E0005B663 = { 182 | CreatedOnToolsVersion = 6.1; 183 | }; 184 | 6B34EBD51A39529F0005B663 = { 185 | CreatedOnToolsVersion = 6.1; 186 | TestTargetID = 6B34EBBC1A39529E0005B663; 187 | }; 188 | }; 189 | }; 190 | buildConfigurationList = 6B34EBB81A39529E0005B663 /* Build configuration list for PBXProject "HYPanTableView" */; 191 | compatibilityVersion = "Xcode 3.2"; 192 | developmentRegion = English; 193 | hasScannedForEncodings = 0; 194 | knownRegions = ( 195 | en, 196 | Base, 197 | ); 198 | mainGroup = 6B34EBB41A39529E0005B663; 199 | productRefGroup = 6B34EBBE1A39529E0005B663 /* Products */; 200 | projectDirPath = ""; 201 | projectRoot = ""; 202 | targets = ( 203 | 6B34EBBC1A39529E0005B663 /* HYPanTableView */, 204 | 6B34EBD51A39529F0005B663 /* HYPanTableViewTests */, 205 | ); 206 | }; 207 | /* End PBXProject section */ 208 | 209 | /* Begin PBXResourcesBuildPhase section */ 210 | 6B34EBBB1A39529E0005B663 /* Resources */ = { 211 | isa = PBXResourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | D8AADA321A3C9479002C2EEA /* LaunchScreen.xib in Resources */, 215 | D8AADA341A3C9479002C2EEA /* Images.xcassets in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | 6B34EBD41A39529F0005B663 /* Resources */ = { 220 | isa = PBXResourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | /* End PBXResourcesBuildPhase section */ 227 | 228 | /* Begin PBXSourcesBuildPhase section */ 229 | 6B34EBB91A39529E0005B663 /* Sources */ = { 230 | isa = PBXSourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | D8AADA311A3C9479002C2EEA /* AppDelegate.m in Sources */, 234 | D8AADA361A3C9479002C2EEA /* main.m in Sources */, 235 | D8AADA371A3C9479002C2EEA /* ViewController.m in Sources */, 236 | 9607F4D71AA1A7BC00943169 /* HYSnapshotView.m in Sources */, 237 | D8AADA331A3C9479002C2EEA /* DetailViewController.m in Sources */, 238 | 9607F4DD1AA1AFD800943169 /* HYPanGestureRecognizer.m in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | 6B34EBD21A39529F0005B663 /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 6B34EBDD1A39529F0005B663 /* HYPanTableViewTests.m in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | 6B34EBD81A39529F0005B663 /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | target = 6B34EBBC1A39529E0005B663 /* HYPanTableView */; 256 | targetProxy = 6B34EBD71A39529F0005B663 /* PBXContainerItemProxy */; 257 | }; 258 | /* End PBXTargetDependency section */ 259 | 260 | /* Begin PBXVariantGroup section */ 261 | D8AADA281A3C9479002C2EEA /* LaunchScreen.xib */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | D8AADA291A3C9479002C2EEA /* Base */, 265 | ); 266 | name = LaunchScreen.xib; 267 | sourceTree = ""; 268 | }; 269 | /* End PBXVariantGroup section */ 270 | 271 | /* Begin XCBuildConfiguration section */ 272 | 6B34EBDE1A39529F0005B663 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 277 | CLANG_CXX_LIBRARY = "libc++"; 278 | CLANG_ENABLE_MODULES = YES; 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_EMPTY_BODY = YES; 284 | CLANG_WARN_ENUM_CONVERSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN_UNREACHABLE_CODE = YES; 288 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 290 | COPY_PHASE_STRIP = NO; 291 | ENABLE_STRICT_OBJC_MSGSEND = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_DYNAMIC_NO_PIC = NO; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 307 | MTL_ENABLE_DEBUG_INFO = YES; 308 | ONLY_ACTIVE_ARCH = YES; 309 | SDKROOT = iphoneos; 310 | }; 311 | name = Debug; 312 | }; 313 | 6B34EBDF1A39529F0005B663 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INT_CONVERSION = YES; 327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = YES; 332 | ENABLE_NS_ASSERTIONS = NO; 333 | ENABLE_STRICT_OBJC_MSGSEND = YES; 334 | GCC_C_LANGUAGE_STANDARD = gnu99; 335 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 336 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 337 | GCC_WARN_UNDECLARED_SELECTOR = YES; 338 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 339 | GCC_WARN_UNUSED_FUNCTION = YES; 340 | GCC_WARN_UNUSED_VARIABLE = YES; 341 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 342 | MTL_ENABLE_DEBUG_INFO = NO; 343 | SDKROOT = iphoneos; 344 | VALIDATE_PRODUCT = YES; 345 | }; 346 | name = Release; 347 | }; 348 | 6B34EBE11A39529F0005B663 /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 352 | INFOPLIST_FILE = HYPanTableViewDemo/Info.plist; 353 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 354 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 355 | PRODUCT_NAME = "$(TARGET_NAME)"; 356 | }; 357 | name = Debug; 358 | }; 359 | 6B34EBE21A39529F0005B663 /* Release */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 363 | INFOPLIST_FILE = HYPanTableViewDemo/Info.plist; 364 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | }; 368 | name = Release; 369 | }; 370 | 6B34EBE41A39529F0005B663 /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | BUNDLE_LOADER = "$(TEST_HOST)"; 374 | FRAMEWORK_SEARCH_PATHS = ( 375 | "$(SDKROOT)/Developer/Library/Frameworks", 376 | "$(inherited)", 377 | ); 378 | GCC_PREPROCESSOR_DEFINITIONS = ( 379 | "DEBUG=1", 380 | "$(inherited)", 381 | ); 382 | INFOPLIST_FILE = HYPanTableViewTests/Info.plist; 383 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HYPanTableView.app/HYPanTableView"; 386 | }; 387 | name = Debug; 388 | }; 389 | 6B34EBE51A39529F0005B663 /* Release */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | BUNDLE_LOADER = "$(TEST_HOST)"; 393 | FRAMEWORK_SEARCH_PATHS = ( 394 | "$(SDKROOT)/Developer/Library/Frameworks", 395 | "$(inherited)", 396 | ); 397 | INFOPLIST_FILE = HYPanTableViewTests/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 399 | PRODUCT_NAME = "$(TARGET_NAME)"; 400 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/HYPanTableView.app/HYPanTableView"; 401 | }; 402 | name = Release; 403 | }; 404 | /* End XCBuildConfiguration section */ 405 | 406 | /* Begin XCConfigurationList section */ 407 | 6B34EBB81A39529E0005B663 /* Build configuration list for PBXProject "HYPanTableView" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | 6B34EBDE1A39529F0005B663 /* Debug */, 411 | 6B34EBDF1A39529F0005B663 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | 6B34EBE01A39529F0005B663 /* Build configuration list for PBXNativeTarget "HYPanTableView" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | 6B34EBE11A39529F0005B663 /* Debug */, 420 | 6B34EBE21A39529F0005B663 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | 6B34EBE31A39529F0005B663 /* Build configuration list for PBXNativeTarget "HYPanTableViewTests" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 6B34EBE41A39529F0005B663 /* Debug */, 429 | 6B34EBE51A39529F0005B663 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | /* End XCConfigurationList section */ 435 | }; 436 | rootObject = 6B34EBB51A39529E0005B663 /* Project object */; 437 | } 438 | -------------------------------------------------------------------------------- /HYPanTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanwhy/HYPanViewController/64a1b99a0d7836c1912a5dd32263f83063e87386/HYPanTableViewDemo/.DS_Store -------------------------------------------------------------------------------- /HYPanTableViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 21 | [self.window setBackgroundColor:[UIColor blackColor]]; 22 | 23 | ViewController *main = [[ViewController alloc] init]; 24 | [self.window setRootViewController:main]; 25 | 26 | [self.window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | @end 30 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/DetailViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.h 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DetailViewController : UIViewController 12 | 13 | 14 | - (void)back; 15 | @end 16 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/DetailViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.m 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import "DetailViewController.h" 10 | 11 | @interface DetailViewController () 12 | { 13 | UITextView *_textView; 14 | } 15 | @end 16 | 17 | @implementation DetailViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | self.view.alpha = 0.7f; 23 | self.view.backgroundColor = [UIColor grayColor]; 24 | 25 | UITextView *textView = [[UITextView alloc] init]; 26 | textView.frame = CGRectMake(10, -180, self.view.frame.size.width-20, 180); 27 | textView.backgroundColor = [UIColor whiteColor]; 28 | [self.view addSubview:textView]; 29 | 30 | UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 31 | [cancelBtn setTitle:@"cancel" forState:UIControlStateNormal]; 32 | [cancelBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 33 | [cancelBtn setFrame:CGRectMake(0, textView.frame.size.height-30, 60, 30)]; 34 | [cancelBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; 35 | [textView addSubview:cancelBtn]; 36 | 37 | UIButton *commitBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 38 | [commitBtn setTitle:@"send" forState:UIControlStateNormal]; 39 | [commitBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal]; 40 | [commitBtn setFrame:CGRectMake(textView.frame.size.width-60, textView.frame.size.height-30, 60, 30)]; 41 | [commitBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; 42 | [textView addSubview:commitBtn]; 43 | 44 | 45 | _textView = textView; 46 | 47 | [self showView]; 48 | 49 | } 50 | 51 | 52 | - (void)showView{ 53 | [UIView animateWithDuration:0.3 animations:^{ 54 | _textView.transform = CGAffineTransformMakeTranslation(0, 210); 55 | }]; 56 | [_textView becomeFirstResponder]; 57 | } 58 | 59 | - (void)back{ 60 | typeof(self) __weak weakSelf = self; 61 | [UIView animateWithDuration:0.3 animations:^{ 62 | _textView.transform = CGAffineTransformMakeTranslation(0, -210); 63 | } completion:^(BOOL finished) { 64 | [weakSelf willMoveToParentViewController:nil]; 65 | [weakSelf.view removeFromSuperview]; 66 | [weakSelf removeFromParentViewController]; 67 | }]; 68 | 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /HYPanTableViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.idu.proj.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // HYPanTableView 4 | // 5 | // Created by nathan on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DetailViewController.h" 11 | #import "HYPanGestureRecognizer.h" 12 | 13 | #define DF_Color_RGB(a,b,c) [UIColor colorWithRed:a/255.0f green:b/255.0f blue:c/255.0f alpha:1] 14 | @interface ViewController () 15 | 16 | @property (nonatomic, strong)UITableView *tableView; 17 | @property (nonatomic, strong)NSMutableArray *dataList; 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | self.dataList = [NSMutableArray arrayWithArray:@[@"Beauty! Where is thy faith?", 25 | @"Keep up your bright swords, for the dew will rust them. ", 26 | @"O, she dothe teach the torches to burn bright! ", 27 | @"Nothing will come of nothing. ", 28 | @"This above all: to thine self be true.", 29 | @"A little more than kin, and less than kind. ", 30 | @"no zuo no die", 31 | @"Beauty! Where is thy faith?", 32 | @"Keep up your bright swords, for the dew will rust them. ", 33 | @"O, she dothe teach the torches to burn bright! ", 34 | @"Nothing will come of nothing. ", 35 | @"This above all: to thine self be true.", 36 | @"A little more than kin, and less than kind. "]]; 37 | 38 | _tableView = ({ 39 | UITableView *tableview = [[UITableView alloc] initWithFrame:self.view.frame]; 40 | tableview.delegate = self; 41 | tableview.dataSource = self; 42 | [self.view addSubview:tableview]; 43 | tableview; 44 | }); 45 | 46 | typeof(self) __weak weakSelf = self; 47 | HYPanGestureRecognizer *pan = [[HYPanGestureRecognizer alloc] initWithTabelView:_tableView Handler:^(HYPanGestureRecognizer *panGesture, NSIndexPath *indexpath, BOOL isLeft) { 48 | 49 | if (isLeft) { 50 | [weakSelf.dataList removeObjectAtIndex:indexpath.row]; 51 | [panGesture.tableView deleteRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationFade]; 52 | 53 | }else{ 54 | DetailViewController *detail = [[DetailViewController alloc] init]; 55 | [weakSelf addChildViewController:detail]; 56 | [weakSelf.view addSubview:detail.view]; 57 | [detail didMoveToParentViewController:weakSelf]; 58 | } 59 | }]; 60 | [pan addLeftText:@"comment" rightText:@"retweet"]; 61 | [self.view addGestureRecognizer:pan]; 62 | } 63 | 64 | #pragma mark - tableView DataSource 65 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 66 | return [self.dataList count]; 67 | } 68 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 69 | return 90; 70 | } 71 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 72 | static NSString *cellid = @"cell"; 73 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid]; 74 | if (cell == nil) { 75 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid]; 76 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 77 | cell.textLabel.numberOfLines = 0; 78 | } 79 | cell.textLabel.text = self.dataList[indexPath.row]; 80 | cell.backgroundColor = DF_Color_RGB(245, 240, 235); 81 | 82 | return cell; 83 | } 84 | 85 | 86 | 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /HYPanTableViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HYPanTableView 4 | // 5 | // Created by DOIT on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HYPanTableViewTests/HYPanTableViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HYPanTableViewTests.m 3 | // HYPanTableViewTests 4 | // 5 | // Created by DOIT on 14-12-11. 6 | // Copyright (c) 2014年 nathanwu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface HYPanTableViewTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation HYPanTableViewTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | // [self measureBlock:^{ 36 | // // Put the code you want to measure the time of here. 37 | // }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /HYPanTableViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.idu.proj.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 nathan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HYPanViewController 2 | =================== 3 | The ViewController that recreates the vvebo app UI. 4 | The Awesome way to delete tableView cell or present new viewController. 5 | 6 | ![image](https://github.com/nathanwhy/HYPanViewController/raw/master/screenshot.gif) 7 | 8 | 9 | 10 | ###Usage 11 | 12 | You can use `handler` to present new view controller: 13 | 14 | ```objc 15 | typeof(self) __weak weakSelf = self; 16 | HYPanGestureRecognizer *pan = [[HYPanGestureRecognizer alloc] initWithTabelView:_tableView Handler:^(HYPanGestureRecognizer *panGesture, NSIndexPath *indexpath, BOOL isLeft) { 17 | 18 | if (isLeft) { 19 | DetailViewController *detail = [[DetailViewController alloc] init]; 20 | [weakSelf addChildViewController:detail]; 21 | [weakSelf.view addSubview:detail.view]; 22 | [detail didMoveToParentViewController:weakSelf]; 23 | } 24 | }]; 25 | [pan addLeftText:@"comment" rightText:@"retweet"]; 26 | [self.view addGestureRecognizer:pan]; 27 | ``` 28 | 29 | 30 | It also can be used to delete Cell: 31 | 32 | ```objc 33 | typeof(self) __weak weakSelf = self; 34 | HYPanGestureRecognizer *pan = [[HYPanGestureRecognizer alloc] initWithTabelView:_tableView Handler:^(HYPanGestureRecognizer *panGesture, NSIndexPath *indexpath, BOOL isLeft) { 35 | 36 | if (!isLeft) { 37 | [weakSelf.dataList removeObjectAtIndex:indexpath.row]; 38 | [panGesture.tableView deleteRowsAtIndexPaths:@[indexpath] withRowAnimation:UITableViewRowAnimationFade]; 39 | } 40 | }]; 41 | [pan addLeftText:@"comment" rightText:@"delete"]; 42 | [self.view addGestureRecognizer:pan]; 43 | ``` 44 | 45 | 46 | This project is inspired by [Udo](https://github.com/moayes/UDo/tree/master) . 47 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanwhy/HYPanViewController/64a1b99a0d7836c1912a5dd32263f83063e87386/screenshot.gif --------------------------------------------------------------------------------