├── .gitignore ├── .travis.yml ├── Classes ├── SCAvatarBrowser.h └── SCAvatarBrowser.m ├── LICENSE ├── README.md ├── SCAvatarBrowser.podspec ├── SCAvatarBrowserDemo ├── SCAvatarBrowserDemo.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── SCAvatarBrowserDemo.xcscheme ├── SCAvatarBrowserDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── cat.jpg │ └── main.m └── SCAvatarBrowserDemoTests │ ├── Info.plist │ └── SCAvatarBrowserDemoTests.m └── Screenshots ├── demo.gif └── demo.mp4 /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | 17 | # osx noise 18 | .DS_Store 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7.0 3 | xcode_sdk: 4 | - iphonesimulator9.0 5 | script: 6 | - xctool -project SCAvatarBrowserDemo/SCAvatarBrowserDemo.xcodeproj -scheme SCAvatarBrowserDemo -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -------------------------------------------------------------------------------- /Classes/SCAvatarBrowser.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCAvatarBrowser.h 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/3. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SCAvatarBrowser : UIViewController 12 | 13 | + (void)showImageView:(UIImageView *)avatarImageView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Classes/SCAvatarBrowser.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAvatarBrowser.m 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/3. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import "SCAvatarBrowser.h" 10 | 11 | static CGRect avatarFrame; 12 | static UIImageView *newAvatarImageView; 13 | static CGFloat currentScale; 14 | static CGFloat screenWidth; 15 | static CGFloat screenHeight; 16 | 17 | @implementation SCAvatarBrowser 18 | 19 | + (void)showImageView:(UIImageView *)avatarImageView { 20 | if (avatarImageView == nil) { 21 | NSLog(@"avatarImageView is nil"); 22 | return; 23 | } 24 | 25 | screenWidth = [UIScreen mainScreen].bounds.size.width; 26 | screenHeight = [UIScreen mainScreen].bounds.size.height; 27 | 28 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; 29 | UIImage *avatarImage = [avatarImageView image]; 30 | 31 | // black background contains the avatar image 32 | UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)]; 33 | [background setBackgroundColor:[UIColor blackColor]]; 34 | [background setAlpha:0]; 35 | 36 | // same size of original image 37 | avatarFrame = [avatarImageView convertRect:avatarImageView.bounds toView:keyWindow]; 38 | newAvatarImageView = [[UIImageView alloc] initWithFrame:avatarFrame]; 39 | [newAvatarImageView setImage:avatarImage]; 40 | [newAvatarImageView setUserInteractionEnabled:YES]; 41 | [background addSubview:newAvatarImageView]; 42 | [keyWindow addSubview:background]; 43 | 44 | // make it show on middle 45 | CGFloat proportion = screenWidth / avatarImage.size.width; 46 | CGFloat top = screenHeight / 2 - avatarImage.size.height * proportion / 2; 47 | CGFloat height = avatarImage.size.height * proportion; 48 | 49 | // return to origin view by tap on background 50 | UITapGestureRecognizer *tapOnBackground = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionTapOnImage:)]; 51 | [background addGestureRecognizer:tapOnBackground]; 52 | 53 | // scale by pinch on background 54 | UIPinchGestureRecognizer *pinchOnImage = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(actionPinchOnImage:)]; 55 | [background addGestureRecognizer:pinchOnImage]; 56 | 57 | // move avatar by pan on image 58 | UIPanGestureRecognizer *panOnImage = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(actionPanOnImage:)]; 59 | [newAvatarImageView addGestureRecognizer:panOnImage]; 60 | 61 | // store avatar image by long press on it 62 | UILongPressGestureRecognizer *longPressOnImage = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(actionLongPressOnImage:)]; 63 | longPressOnImage.minimumPressDuration = 0.3f; 64 | [newAvatarImageView addGestureRecognizer:longPressOnImage]; 65 | 66 | // show detail view with animation 67 | [UIView animateWithDuration:0.3f 68 | animations:^ 69 | { 70 | [newAvatarImageView setFrame:CGRectMake(0, top, screenWidth, height)]; 71 | [background setAlpha:1]; 72 | }]; 73 | } 74 | 75 | // tap to return to original view 76 | + (void)actionTapOnImage:(UITapGestureRecognizer *)sender { 77 | UIView *background = [sender view]; 78 | [UIView animateWithDuration:0.3f animations:^ { 79 | [newAvatarImageView setFrame:avatarFrame]; 80 | [background setAlpha:0]; 81 | } completion:^(BOOL finished) { 82 | [background removeFromSuperview]; 83 | newAvatarImageView = nil; 84 | }]; 85 | } 86 | 87 | // pinch to scale the avatar image 88 | + (void)actionPinchOnImage:(UIPinchGestureRecognizer *)sender { 89 | if ([sender state] == UIGestureRecognizerStateEnded) { 90 | currentScale = 1.0f; 91 | if (newAvatarImageView.frame.size.width < screenWidth) { 92 | // avatar image too small 93 | [UIView animateWithDuration:0.5f 94 | animations:^ 95 | { 96 | [newAvatarImageView setCenter:CGPointMake(screenWidth / 2, screenHeight / 2)]; 97 | CGFloat proportion = screenWidth / newAvatarImageView.frame.size.width; 98 | CGAffineTransform currentTransform = newAvatarImageView.transform; 99 | CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, proportion, proportion); 100 | [newAvatarImageView setTransform:newTransform]; 101 | }]; 102 | } else if (newAvatarImageView.frame.size.width > 2 * screenWidth) { 103 | // avatar image too big 104 | [UIView animateWithDuration:0.5f 105 | animations:^ 106 | { 107 | CGFloat proportion = 2 * screenWidth / newAvatarImageView.frame.size.width; 108 | CGAffineTransform currentTransform = newAvatarImageView.transform; 109 | CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, proportion, proportion); 110 | [newAvatarImageView setTransform:newTransform]; 111 | }]; 112 | } 113 | return; 114 | } else { 115 | CGFloat proportion = 1.0 - (currentScale - [sender scale]); 116 | 117 | // slow down when being too big or too small 118 | if (newAvatarImageView.frame.size.width > 2 * screenWidth) { 119 | proportion = 1.01f; 120 | } else if (newAvatarImageView.frame.size.width < 0.8 * screenWidth) { 121 | proportion = 0.99f; 122 | } 123 | 124 | CGAffineTransform currentTransform = newAvatarImageView.transform; 125 | CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, proportion, proportion); 126 | 127 | [newAvatarImageView setTransform:newTransform]; 128 | 129 | currentScale = [sender scale]; 130 | } 131 | } 132 | 133 | // pan to move the avatar image 134 | + (void)actionPanOnImage:(UIPanGestureRecognizer *)sender { 135 | if (newAvatarImageView.frame.size.width < screenWidth + 1) { 136 | return; 137 | } 138 | 139 | CGPoint touchPosition = [sender translationInView:newAvatarImageView]; 140 | CGFloat avatarWidth = newAvatarImageView.frame.size.width; 141 | CGFloat avatarHeight = newAvatarImageView.frame.size.height; 142 | CGFloat moveX = touchPosition.x; 143 | CGFloat moveY = touchPosition.y; 144 | 145 | moveX *= (avatarWidth / screenWidth); 146 | moveY *= (avatarHeight / screenHeight); 147 | 148 | 149 | [sender.view setCenter:CGPointMake(sender.view.center.x + moveX, sender.view.center.y + moveY)]; 150 | [sender setTranslation:CGPointMake(0, 0) inView:newAvatarImageView]; 151 | 152 | // fix avatar's postion when out of view 153 | if ([sender state] == UIGestureRecognizerStateEnded) { 154 | CGFloat newCenterX = screenWidth / 2; 155 | CGFloat newCenterY = screenHeight / 2; 156 | BOOL isCenterChanged = NO; 157 | 158 | // too left or too right 159 | if (newAvatarImageView.frame.origin.x + avatarWidth < screenWidth) { 160 | newCenterX -= (avatarWidth - screenWidth) / 2; 161 | isCenterChanged = YES; 162 | } else if (newAvatarImageView.frame.origin.x > 0) { 163 | newCenterX += (avatarWidth - screenWidth) / 2; 164 | isCenterChanged = YES; 165 | } else { 166 | newCenterX = newAvatarImageView.center.x; 167 | } 168 | 169 | // too top or too bottom 170 | if (avatarHeight > screenHeight) { 171 | if (newAvatarImageView.frame.origin.y + avatarHeight < screenHeight) { 172 | newCenterY -= (avatarHeight - screenHeight) / 2; 173 | isCenterChanged = YES; 174 | } else if (newAvatarImageView.frame.origin.y > 0) { 175 | newCenterY += (avatarHeight - screenHeight) / 2; 176 | isCenterChanged = YES; 177 | } else { 178 | newCenterY = newAvatarImageView.center.y; 179 | } 180 | } 181 | 182 | if (isCenterChanged == YES) { 183 | [UIView animateWithDuration:0.3 animations:^{ 184 | [newAvatarImageView setCenter:CGPointMake(newCenterX , newCenterY)]; 185 | }]; 186 | } 187 | } 188 | } 189 | 190 | // long press to store the avatar 191 | + (void)actionLongPressOnImage:(UILongPressGestureRecognizer *)sender { 192 | if ([sender state] == UIGestureRecognizerStateEnded) { 193 | UIActionSheet *actionSheet = [[UIActionSheet alloc] 194 | initWithTitle:nil 195 | delegate:(id)self cancelButtonTitle:@"cancel" 196 | destructiveButtonTitle:nil 197 | otherButtonTitles:@"save the picture", nil]; 198 | 199 | actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; 200 | [actionSheet showInView:[sender view]]; 201 | } 202 | } 203 | 204 | // select first button to store image 205 | + (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 206 | if (buttonIndex == 0) { 207 | UIImageWriteToSavedPhotosAlbum(newAvatarImageView.image, self, @selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), NULL); 208 | } 209 | } 210 | 211 | // handle error and success 212 | + (void)thisImage:(UIImage *)image hasBeenSavedInPhotoAlbumWithError:(NSError *)error usingContextInfo:(void*)ctxInfo { 213 | if (error) { 214 | NSLog(@"error"); 215 | UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:nil 216 | message:@"fail to store image" 217 | delegate:nil 218 | cancelButtonTitle:@"ok" 219 | otherButtonTitles:nil, nil]; 220 | [errorAlert show]; 221 | } else { 222 | NSLog(@"success"); 223 | UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:nil 224 | message:@"image has benn stored" 225 | delegate:nil 226 | cancelButtonTitle:@"ok" 227 | otherButtonTitles:nil, nil]; 228 | [errorAlert show]; 229 | } 230 | } 231 | 232 | @end 233 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 lsc 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SCAvatarBrowser 2 | 3 | [![Travis CI](https://travis-ci.org/luosch/SCAvatarBrowser.svg)](https://travis-ci.org/luosch/SCAvatarBrowser) 4 | [![Version](https://img.shields.io/cocoapods/v/SCAvatarBrowser.svg?style=flat)](http://cocoadocs.org/docsets/SCAvatarBrowser/) 5 | [![Pod Platform](http://img.shields.io/cocoapods/p/SCAvatarBrowser.svg?style=flat)](http://cocoadocs.org/docsets/SCAvatarBrowser/) 6 | [![License](https://img.shields.io/cocoapods/l/SCAvatarBrowser.svg?style=flat)](https://github.com/luosch/SCAvatarBrowser/blob/master/LICENSE) 7 | 8 | ## Screenshots 9 | 10 | ![](https://raw.githubusercontent.com/luosch/SCAvatarBrowser/master/Screenshots/demo.gif) 11 | 12 | ## Overview 13 | 14 | `SCAvatarBrowser` is a powerful and lightweight tool to create the view used to enlarge photos from their avatar previews. 15 | 16 | By using `SCAvatarBrowser`, you can make your avatar scalable, draggable and storable within just one line. 17 | 18 | ```objective-c 19 | [SCAvatarBrowser showImage:self.avatar]; 20 | ``` 21 | 22 | ## Installation 23 | Using Pod 24 | 25 | pod 'SCAvatarBrowser' 26 | 27 | Or drag `SCAvatarBrowser.h` and `SCAvatarBrowser.m` files into your project, and then include "`SCAvatarBrowser.h`" where needed, or in your precompiled header. 28 | 29 | The project uses ARC and targets iOS 7.0+. 30 | 31 | ## Usage Examples 32 | 33 | ```objective-c 34 | #import "SCAvatarBrowser.h" 35 | ... 36 | ... 37 | ... 38 | - (void)showAvatarDetailView { 39 | [SCAvatarBrowser showImageView:self.avatar]; 40 | } 41 | ``` 42 | 43 | ## TODO 44 | 45 | - ~~Create one example~~ (added 2015/09/04) 46 | - ~~Support for drag and sacle~~ (added 2015/09/08) 47 | - ~~Support for store image to local photo library~~ (added 2015/09/08) 48 | - ~~Add CocoaPods spec~~ (added 2015/11/11) 49 | 50 | ## License 51 | 52 | All source code is licensed under the [MIT License](https://raw.githubusercontent.com/luosch/SCAvatarBrowser/master/LICENSE). -------------------------------------------------------------------------------- /SCAvatarBrowser.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'SCAvatarBrowser' 3 | spec.version = '1.1.0' 4 | spec.license = { :type => 'MIT', :file => 'LICENSE' } 5 | spec.homepage = 'https://github.com/luosch/SCAvatarBrowser' 6 | spec.authors = { 'Sicheng Luo' => 'me@lsich.com' } 7 | spec.summary = 'provide detail view of thumb image for iOS' 8 | spec.source = { :git => 'https://github.com/luosch/SCAvatarBrowser.git', :tag => 'v1.1.0'} 9 | spec.source_files = 'Classes/*.{h,m}' 10 | spec.framework = 'Foundation', 'UIKit' 11 | spec.requires_arc = true 12 | spec.platform = :ios, '7.0' 13 | end -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 415E78AF1B9745C70043102A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 415E78AE1B9745C70043102A /* main.m */; }; 11 | 415E78B21B9745C70043102A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 415E78B11B9745C70043102A /* AppDelegate.m */; }; 12 | 415E78B51B9745C70043102A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 415E78B41B9745C70043102A /* ViewController.m */; }; 13 | 415E78B81B9745C70043102A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 415E78B61B9745C70043102A /* Main.storyboard */; }; 14 | 415E78BA1B9745C70043102A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 415E78B91B9745C70043102A /* Images.xcassets */; }; 15 | 415E78BD1B9745C70043102A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 415E78BB1B9745C70043102A /* LaunchScreen.xib */; }; 16 | 415E78C91B9745C80043102A /* SCAvatarBrowserDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 415E78C81B9745C80043102A /* SCAvatarBrowserDemoTests.m */; }; 17 | 415E78D41B9748850043102A /* cat.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 415E78D31B9748850043102A /* cat.jpg */; }; 18 | 41F307B51B9891D100F96CC4 /* SCAvatarBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 41F307B41B9891D100F96CC4 /* SCAvatarBrowser.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 415E78C31B9745C80043102A /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 415E78A11B9745C70043102A /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 415E78A81B9745C70043102A; 27 | remoteInfo = SCAvatarBrowserDemo; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 415E78A91B9745C70043102A /* SCAvatarBrowserDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SCAvatarBrowserDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 415E78AD1B9745C70043102A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 415E78AE1B9745C70043102A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | 415E78B01B9745C70043102A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | 415E78B11B9745C70043102A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | 415E78B31B9745C70043102A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | 415E78B41B9745C70043102A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | 415E78B71B9745C70043102A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | 415E78B91B9745C70043102A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | 415E78BC1B9745C70043102A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | 415E78C21B9745C80043102A /* SCAvatarBrowserDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCAvatarBrowserDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 415E78C71B9745C80043102A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 415E78C81B9745C80043102A /* SCAvatarBrowserDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SCAvatarBrowserDemoTests.m; sourceTree = ""; }; 45 | 415E78D31B9748850043102A /* cat.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = cat.jpg; path = SCAvatarBrowserDemo/cat.jpg; sourceTree = ""; }; 46 | 41F307B31B9891D100F96CC4 /* SCAvatarBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SCAvatarBrowser.h; path = ../../Classes/SCAvatarBrowser.h; sourceTree = ""; }; 47 | 41F307B41B9891D100F96CC4 /* SCAvatarBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SCAvatarBrowser.m; path = ../../Classes/SCAvatarBrowser.m; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | 415E78A61B9745C70043102A /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | 415E78BF1B9745C80043102A /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 415E78A01B9745C70043102A = { 69 | isa = PBXGroup; 70 | children = ( 71 | 415E78AB1B9745C70043102A /* SCAvatarBrowserDemo */, 72 | 415E78C51B9745C80043102A /* SCAvatarBrowserDemoTests */, 73 | 415E78AA1B9745C70043102A /* Products */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | 415E78AA1B9745C70043102A /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 415E78A91B9745C70043102A /* SCAvatarBrowserDemo.app */, 81 | 415E78C21B9745C80043102A /* SCAvatarBrowserDemoTests.xctest */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 415E78AB1B9745C70043102A /* SCAvatarBrowserDemo */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 415E78DB1B974E730043102A /* SCAvatarBrowser */, 90 | 415E78D21B97485C0043102A /* Asset */, 91 | 415E78B01B9745C70043102A /* AppDelegate.h */, 92 | 415E78B11B9745C70043102A /* AppDelegate.m */, 93 | 415E78B31B9745C70043102A /* ViewController.h */, 94 | 415E78B41B9745C70043102A /* ViewController.m */, 95 | 415E78B61B9745C70043102A /* Main.storyboard */, 96 | 415E78B91B9745C70043102A /* Images.xcassets */, 97 | 415E78BB1B9745C70043102A /* LaunchScreen.xib */, 98 | 415E78AC1B9745C70043102A /* Supporting Files */, 99 | ); 100 | path = SCAvatarBrowserDemo; 101 | sourceTree = ""; 102 | }; 103 | 415E78AC1B9745C70043102A /* Supporting Files */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 415E78AD1B9745C70043102A /* Info.plist */, 107 | 415E78AE1B9745C70043102A /* main.m */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 415E78C51B9745C80043102A /* SCAvatarBrowserDemoTests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 415E78C81B9745C80043102A /* SCAvatarBrowserDemoTests.m */, 116 | 415E78C61B9745C80043102A /* Supporting Files */, 117 | ); 118 | path = SCAvatarBrowserDemoTests; 119 | sourceTree = ""; 120 | }; 121 | 415E78C61B9745C80043102A /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 415E78C71B9745C80043102A /* Info.plist */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 415E78D21B97485C0043102A /* Asset */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 415E78D31B9748850043102A /* cat.jpg */, 133 | ); 134 | name = Asset; 135 | path = ..; 136 | sourceTree = ""; 137 | }; 138 | 415E78DB1B974E730043102A /* SCAvatarBrowser */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 41F307B31B9891D100F96CC4 /* SCAvatarBrowser.h */, 142 | 41F307B41B9891D100F96CC4 /* SCAvatarBrowser.m */, 143 | ); 144 | name = SCAvatarBrowser; 145 | sourceTree = ""; 146 | }; 147 | /* End PBXGroup section */ 148 | 149 | /* Begin PBXNativeTarget section */ 150 | 415E78A81B9745C70043102A /* SCAvatarBrowserDemo */ = { 151 | isa = PBXNativeTarget; 152 | buildConfigurationList = 415E78CC1B9745C80043102A /* Build configuration list for PBXNativeTarget "SCAvatarBrowserDemo" */; 153 | buildPhases = ( 154 | 415E78A51B9745C70043102A /* Sources */, 155 | 415E78A61B9745C70043102A /* Frameworks */, 156 | 415E78A71B9745C70043102A /* Resources */, 157 | ); 158 | buildRules = ( 159 | ); 160 | dependencies = ( 161 | ); 162 | name = SCAvatarBrowserDemo; 163 | productName = SCAvatarBrowserDemo; 164 | productReference = 415E78A91B9745C70043102A /* SCAvatarBrowserDemo.app */; 165 | productType = "com.apple.product-type.application"; 166 | }; 167 | 415E78C11B9745C80043102A /* SCAvatarBrowserDemoTests */ = { 168 | isa = PBXNativeTarget; 169 | buildConfigurationList = 415E78CF1B9745C80043102A /* Build configuration list for PBXNativeTarget "SCAvatarBrowserDemoTests" */; 170 | buildPhases = ( 171 | 415E78BE1B9745C80043102A /* Sources */, 172 | 415E78BF1B9745C80043102A /* Frameworks */, 173 | 415E78C01B9745C80043102A /* Resources */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | 415E78C41B9745C80043102A /* PBXTargetDependency */, 179 | ); 180 | name = SCAvatarBrowserDemoTests; 181 | productName = SCAvatarBrowserDemoTests; 182 | productReference = 415E78C21B9745C80043102A /* SCAvatarBrowserDemoTests.xctest */; 183 | productType = "com.apple.product-type.bundle.unit-test"; 184 | }; 185 | /* End PBXNativeTarget section */ 186 | 187 | /* Begin PBXProject section */ 188 | 415E78A11B9745C70043102A /* Project object */ = { 189 | isa = PBXProject; 190 | attributes = { 191 | LastUpgradeCheck = 0640; 192 | ORGANIZATIONNAME = "罗思成"; 193 | TargetAttributes = { 194 | 415E78A81B9745C70043102A = { 195 | CreatedOnToolsVersion = 6.4; 196 | }; 197 | 415E78C11B9745C80043102A = { 198 | CreatedOnToolsVersion = 6.4; 199 | TestTargetID = 415E78A81B9745C70043102A; 200 | }; 201 | }; 202 | }; 203 | buildConfigurationList = 415E78A41B9745C70043102A /* Build configuration list for PBXProject "SCAvatarBrowserDemo" */; 204 | compatibilityVersion = "Xcode 3.2"; 205 | developmentRegion = English; 206 | hasScannedForEncodings = 0; 207 | knownRegions = ( 208 | en, 209 | Base, 210 | ); 211 | mainGroup = 415E78A01B9745C70043102A; 212 | productRefGroup = 415E78AA1B9745C70043102A /* Products */; 213 | projectDirPath = ""; 214 | projectRoot = ""; 215 | targets = ( 216 | 415E78A81B9745C70043102A /* SCAvatarBrowserDemo */, 217 | 415E78C11B9745C80043102A /* SCAvatarBrowserDemoTests */, 218 | ); 219 | }; 220 | /* End PBXProject section */ 221 | 222 | /* Begin PBXResourcesBuildPhase section */ 223 | 415E78A71B9745C70043102A /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | 415E78B81B9745C70043102A /* Main.storyboard in Resources */, 228 | 415E78BD1B9745C70043102A /* LaunchScreen.xib in Resources */, 229 | 415E78D41B9748850043102A /* cat.jpg in Resources */, 230 | 415E78BA1B9745C70043102A /* Images.xcassets in Resources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | 415E78C01B9745C80043102A /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | /* End PBXResourcesBuildPhase section */ 242 | 243 | /* Begin PBXSourcesBuildPhase section */ 244 | 415E78A51B9745C70043102A /* Sources */ = { 245 | isa = PBXSourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | 415E78B51B9745C70043102A /* ViewController.m in Sources */, 249 | 41F307B51B9891D100F96CC4 /* SCAvatarBrowser.m in Sources */, 250 | 415E78B21B9745C70043102A /* AppDelegate.m in Sources */, 251 | 415E78AF1B9745C70043102A /* main.m in Sources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | 415E78BE1B9745C80043102A /* Sources */ = { 256 | isa = PBXSourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | 415E78C91B9745C80043102A /* SCAvatarBrowserDemoTests.m in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXSourcesBuildPhase section */ 264 | 265 | /* Begin PBXTargetDependency section */ 266 | 415E78C41B9745C80043102A /* PBXTargetDependency */ = { 267 | isa = PBXTargetDependency; 268 | target = 415E78A81B9745C70043102A /* SCAvatarBrowserDemo */; 269 | targetProxy = 415E78C31B9745C80043102A /* PBXContainerItemProxy */; 270 | }; 271 | /* End PBXTargetDependency section */ 272 | 273 | /* Begin PBXVariantGroup section */ 274 | 415E78B61B9745C70043102A /* Main.storyboard */ = { 275 | isa = PBXVariantGroup; 276 | children = ( 277 | 415E78B71B9745C70043102A /* Base */, 278 | ); 279 | name = Main.storyboard; 280 | sourceTree = ""; 281 | }; 282 | 415E78BB1B9745C70043102A /* LaunchScreen.xib */ = { 283 | isa = PBXVariantGroup; 284 | children = ( 285 | 415E78BC1B9745C70043102A /* Base */, 286 | ); 287 | name = LaunchScreen.xib; 288 | sourceTree = ""; 289 | }; 290 | /* End PBXVariantGroup section */ 291 | 292 | /* Begin XCBuildConfiguration section */ 293 | 415E78CA1B9745C80043102A /* Debug */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ALWAYS_SEARCH_USER_PATHS = NO; 297 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 298 | CLANG_CXX_LIBRARY = "libc++"; 299 | CLANG_ENABLE_MODULES = YES; 300 | CLANG_ENABLE_OBJC_ARC = YES; 301 | CLANG_WARN_BOOL_CONVERSION = YES; 302 | CLANG_WARN_CONSTANT_CONVERSION = YES; 303 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 304 | CLANG_WARN_EMPTY_BODY = YES; 305 | CLANG_WARN_ENUM_CONVERSION = YES; 306 | CLANG_WARN_INT_CONVERSION = YES; 307 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 308 | CLANG_WARN_UNREACHABLE_CODE = YES; 309 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 310 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 311 | COPY_PHASE_STRIP = NO; 312 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 313 | ENABLE_STRICT_OBJC_MSGSEND = YES; 314 | GCC_C_LANGUAGE_STANDARD = gnu99; 315 | GCC_DYNAMIC_NO_PIC = NO; 316 | GCC_NO_COMMON_BLOCKS = YES; 317 | GCC_OPTIMIZATION_LEVEL = 0; 318 | GCC_PREPROCESSOR_DEFINITIONS = ( 319 | "DEBUG=1", 320 | "$(inherited)", 321 | ); 322 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 330 | MTL_ENABLE_DEBUG_INFO = YES; 331 | ONLY_ACTIVE_ARCH = YES; 332 | SDKROOT = iphoneos; 333 | }; 334 | name = Debug; 335 | }; 336 | 415E78CB1B9745C80043102A /* Release */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 341 | CLANG_CXX_LIBRARY = "libc++"; 342 | CLANG_ENABLE_MODULES = YES; 343 | CLANG_ENABLE_OBJC_ARC = YES; 344 | CLANG_WARN_BOOL_CONVERSION = YES; 345 | CLANG_WARN_CONSTANT_CONVERSION = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_EMPTY_BODY = YES; 348 | CLANG_WARN_ENUM_CONVERSION = YES; 349 | CLANG_WARN_INT_CONVERSION = YES; 350 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 356 | ENABLE_NS_ASSERTIONS = NO; 357 | ENABLE_STRICT_OBJC_MSGSEND = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_NO_COMMON_BLOCKS = YES; 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 367 | MTL_ENABLE_DEBUG_INFO = NO; 368 | SDKROOT = iphoneos; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | 415E78CD1B9745C80043102A /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | INFOPLIST_FILE = SCAvatarBrowserDemo/Info.plist; 378 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | }; 382 | name = Debug; 383 | }; 384 | 415E78CE1B9745C80043102A /* Release */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | INFOPLIST_FILE = SCAvatarBrowserDemo/Info.plist; 389 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 390 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | }; 393 | name = Release; 394 | }; 395 | 415E78D01B9745C80043102A /* Debug */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | BUNDLE_LOADER = "$(TEST_HOST)"; 399 | FRAMEWORK_SEARCH_PATHS = ( 400 | "$(SDKROOT)/Developer/Library/Frameworks", 401 | "$(inherited)", 402 | ); 403 | GCC_PREPROCESSOR_DEFINITIONS = ( 404 | "DEBUG=1", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = SCAvatarBrowserDemoTests/Info.plist; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCAvatarBrowserDemo.app/SCAvatarBrowserDemo"; 411 | }; 412 | name = Debug; 413 | }; 414 | 415E78D11B9745C80043102A /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(TEST_HOST)"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | ); 422 | INFOPLIST_FILE = SCAvatarBrowserDemoTests/Info.plist; 423 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 424 | PRODUCT_NAME = "$(TARGET_NAME)"; 425 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCAvatarBrowserDemo.app/SCAvatarBrowserDemo"; 426 | }; 427 | name = Release; 428 | }; 429 | /* End XCBuildConfiguration section */ 430 | 431 | /* Begin XCConfigurationList section */ 432 | 415E78A41B9745C70043102A /* Build configuration list for PBXProject "SCAvatarBrowserDemo" */ = { 433 | isa = XCConfigurationList; 434 | buildConfigurations = ( 435 | 415E78CA1B9745C80043102A /* Debug */, 436 | 415E78CB1B9745C80043102A /* Release */, 437 | ); 438 | defaultConfigurationIsVisible = 0; 439 | defaultConfigurationName = Release; 440 | }; 441 | 415E78CC1B9745C80043102A /* Build configuration list for PBXNativeTarget "SCAvatarBrowserDemo" */ = { 442 | isa = XCConfigurationList; 443 | buildConfigurations = ( 444 | 415E78CD1B9745C80043102A /* Debug */, 445 | 415E78CE1B9745C80043102A /* Release */, 446 | ); 447 | defaultConfigurationIsVisible = 0; 448 | defaultConfigurationName = Release; 449 | }; 450 | 415E78CF1B9745C80043102A /* Build configuration list for PBXNativeTarget "SCAvatarBrowserDemoTests" */ = { 451 | isa = XCConfigurationList; 452 | buildConfigurations = ( 453 | 415E78D01B9745C80043102A /* Debug */, 454 | 415E78D11B9745C80043102A /* Release */, 455 | ); 456 | defaultConfigurationIsVisible = 0; 457 | defaultConfigurationName = Release; 458 | }; 459 | /* End XCConfigurationList section */ 460 | }; 461 | rootObject = 415E78A11B9745C70043102A /* Project object */; 462 | } 463 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo.xcodeproj/xcshareddata/xcschemes/SCAvatarBrowserDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. 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 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/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 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/Base.lproj/Main.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 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/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 | } -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.demo.lsc.$(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 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (strong, nonatomic) UIImageView *avatar; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SCAvatarBrowser.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; 22 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; 23 | CGFloat avatarWidth = 80.0f; 24 | CGFloat avatarHeight = 80.0f; 25 | 26 | // put a circle image on middle view 27 | self.avatar = [[UIImageView alloc] initWithFrame:CGRectMake(screenWidth / 2 - avatarWidth / 2, screenHeight / 2 - avatarHeight / 2 - 40, avatarWidth, avatarHeight)]; 28 | [self.avatar setImage:[UIImage imageNamed:@"cat.jpg"]]; 29 | [self.avatar setUserInteractionEnabled:YES]; 30 | [self.view addSubview:self.avatar]; 31 | 32 | // to be circle 33 | [self.avatar.layer setCornerRadius:avatarWidth / 2]; 34 | [self.avatar.layer setBorderColor:[UIColor whiteColor].CGColor]; 35 | [self.avatar.layer setBorderWidth:1.0f]; 36 | [self.avatar setClipsToBounds:YES]; 37 | 38 | // create tap event for image 39 | UITapGestureRecognizer *tapOnImage = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionTapOnImage)]; 40 | [self.avatar addGestureRecognizer:tapOnImage]; 41 | } 42 | 43 | - (void)actionTapOnImage { 44 | [SCAvatarBrowser showImageView:self.avatar]; 45 | } 46 | 47 | - (void)didReceiveMemoryWarning { 48 | [super didReceiveMemoryWarning]; 49 | // Dispose of any resources that can be recreated. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luosch/SCAvatarBrowser/152bed6d2574b5c007aa879773ab429038eff367/SCAvatarBrowserDemo/SCAvatarBrowserDemo/cat.jpg -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SCAvatarBrowserDemo 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. 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 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.demo.lsc.$(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 | -------------------------------------------------------------------------------- /SCAvatarBrowserDemo/SCAvatarBrowserDemoTests/SCAvatarBrowserDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAvatarBrowserDemoTests.m 3 | // SCAvatarBrowserDemoTests 4 | // 5 | // Created by 罗思成 on 15/9/2. 6 | // Copyright (c) 2015年 罗思成. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface SCAvatarBrowserDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation SCAvatarBrowserDemoTests 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 | -------------------------------------------------------------------------------- /Screenshots/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luosch/SCAvatarBrowser/152bed6d2574b5c007aa879773ab429038eff367/Screenshots/demo.gif -------------------------------------------------------------------------------- /Screenshots/demo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luosch/SCAvatarBrowser/152bed6d2574b5c007aa879773ab429038eff367/Screenshots/demo.mp4 --------------------------------------------------------------------------------