├── .gitignore ├── AZGenieView.h ├── AZGenieView.m ├── GenieTest.xcodeproj └── project.pbxproj ├── GenieTest ├── AZAppDelegate.h ├── AZAppDelegate.m ├── AZViewController.h ├── AZViewController.m ├── GenieTest-Info.plist ├── GenieTest-Prefix.pch ├── IMG_1623.JPG ├── en.lproj │ ├── AZViewController.xib │ └── InfoPlist.strings └── main.m └── README.md /.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 | -------------------------------------------------------------------------------- /AZGenieView.h: -------------------------------------------------------------------------------- 1 | // 2 | // AZGenieView.h 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define AZANIMATION_FRAMERATE 30 12 | #define DRAW_PATH 1 13 | #define PROCESS_ANIMATION 1 14 | 15 | @protocol AZGenieAnimationDelegate 16 | @optional 17 | - (void)geineAnimationDone; 18 | @end 19 | 20 | @interface AZGenieView : UIView 21 | { 22 | bool isAnimation; 23 | NSMutableArray *allFrames; 24 | NSMutableArray *reverseFrames; 25 | NSMutableArray *slices; 26 | CGRect renderFrame; 27 | CGRect targetFrame; 28 | float sliceHeight; 29 | float leftX[960], rightX[960]; 30 | NSTimer *doneTimer; 31 | UIImageView *animationView; 32 | } 33 | 34 | @property (strong, nonatomic) UIImage *renderImage; 35 | @property (assign, nonatomic) CGPathRef renderPath; 36 | @property (assign, nonatomic) id delegate; 37 | 38 | - (void)setRenderFrame:(CGRect)renderFrame andTargetFrame:(CGRect)targetFrame; 39 | - (void)genieAnimationShow:(bool)showing withDuration:(NSTimeInterval)duration; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /AZGenieView.m: -------------------------------------------------------------------------------- 1 | // 2 | // AZGenieView.m 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import "AZGenieView.h" 10 | 11 | @implementation AZGenieView 12 | 13 | //For before Xcode 4.4 14 | @synthesize renderImage; 15 | @synthesize renderPath; 16 | @synthesize delegate; 17 | 18 | - (id)initWithFrame:(CGRect)frame 19 | { 20 | self = [super initWithFrame:frame]; 21 | if (self) { 22 | // Initialization code 23 | self.renderPath = nil; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)awakeFromNib 29 | { 30 | self.renderPath = nil; 31 | } 32 | 33 | #if DRAW_PATH 34 | - (void)drawRect:(CGRect)rect 35 | { 36 | if (self.renderPath==nil) 37 | { 38 | [super drawRect:rect]; 39 | return; 40 | } 41 | 42 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 43 | 44 | CGContextAddPath(ctx, self.renderPath); 45 | CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); 46 | CGContextFillPath(ctx); 47 | } 48 | #endif 49 | 50 | - (void)setImageSlices 51 | { 52 | //Set Image Slices 53 | CGImageRef viewCG = self.renderImage.CGImage; 54 | sliceHeight = 1;//(self.renderImage.size.height/AZANIMATION_SLICE); 55 | slices = [[NSMutableArray alloc] initWithCapacity:self.renderImage.size.height*[[UIScreen mainScreen] scale]]; 56 | for (int i=0; i < self.renderImage.size.height*[[UIScreen mainScreen] scale]; i++) { 57 | [slices addObject:[UIImage imageWithCGImage:CGImageCreateWithImageInRect(viewCG, CGRectMake(0, i*sliceHeight, self.renderImage.size.width*[[UIScreen mainScreen] scale], sliceHeight)) 58 | scale:[[UIScreen mainScreen] scale] 59 | orientation:UIImageOrientationUp]]; 60 | } 61 | } 62 | 63 | - (void)setAnimationFrames 64 | { 65 | CGPoint rightBottom; 66 | float renderLeftUnit, renderRightUnit, renderCurrentX; 67 | int numFrames = AZANIMATION_FRAMERATE/2; 68 | int nFrame = 0; 69 | 70 | CGContextRef bitmap; 71 | CGImageAlphaInfo alphaInfo; 72 | alphaInfo = kCGImageAlphaPremultipliedFirst; 73 | // Build a bitmap context that's the size of the thumbRect 74 | CGFloat bytesPerRow; 75 | int nScale = [[UIScreen mainScreen] scale]; 76 | bytesPerRow = 4 * self.frame.size.width*nScale; 77 | // Draw into the context, this scales the image 78 | for(nFrame=0; nFrame < AZANIMATION_FRAMERATE/2; nFrame++) 79 | { 80 | CGColorSpaceRef colorRGB = CGColorSpaceCreateDeviceRGB(); 81 | bitmap = CGBitmapContextCreate( NULL, 82 | self.frame.size.width*nScale, // width 83 | targetFrame.origin.y*nScale, // height 84 | 8, // really needs to always be 8 85 | bytesPerRow, // rowbytes 86 | colorRGB, 87 | kCGImageAlphaPremultipliedFirst ); 88 | CGContextTranslateCTM(bitmap, 0, targetFrame.origin.y*nScale); 89 | CGContextScaleCTM(bitmap, 1.0*nScale, -1.0*nScale); 90 | for (NSInteger idx = 0; idx < self.renderImage.size.height ; idx++) 91 | { 92 | renderLeftUnit = (leftX[idx]-renderFrame.origin.x)/numFrames; 93 | rightBottom = CGPointMake((renderFrame.origin.x+renderFrame.size.width), 94 | (renderFrame.origin.y+renderFrame.size.height)); 95 | renderRightUnit = (rightBottom.x-rightX[idx])/numFrames ; 96 | renderCurrentX = (renderFrame.origin.x+renderLeftUnit*nFrame); 97 | CGRect clipBox = CGRectMake(renderCurrentX, (renderFrame.origin.y+ idx*sliceHeight), 98 | (rightBottom.x-renderCurrentX)-renderRightUnit*nFrame, sliceHeight); 99 | CGContextSaveGState(bitmap); 100 | CGContextClipToRect(bitmap, clipBox); 101 | CGContextDrawImage(bitmap, clipBox, [[slices objectAtIndex:idx*nScale] CGImage]); 102 | CGContextRestoreGState(bitmap); 103 | } 104 | CGColorSpaceRelease(colorRGB); 105 | CGImageRef ref = CGBitmapContextCreateImage(bitmap); 106 | UIImage* result = [UIImage imageWithCGImage:ref scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp]; 107 | [allFrames addObject:result]; 108 | CGContextRelease(bitmap); 109 | CGImageRelease(ref); 110 | } 111 | 112 | int dropY = (targetFrame.origin.y-renderFrame.origin.y)/(AZANIMATION_FRAMERATE/2); 113 | for(nFrame=0; nFrame < AZANIMATION_FRAMERATE/2; nFrame++) 114 | { 115 | CGColorSpaceRef colorRGB = CGColorSpaceCreateDeviceRGB(); 116 | bitmap = CGBitmapContextCreate( NULL, 117 | self.frame.size.width*nScale, // width 118 | targetFrame.origin.y*nScale, // height 119 | 8, // really needs to always be 8 120 | bytesPerRow, // rowbytes 121 | colorRGB, 122 | kCGImageAlphaPremultipliedFirst ); 123 | CGContextTranslateCTM(bitmap, 0, targetFrame.origin.y*nScale); 124 | CGContextScaleCTM(bitmap, 1.0*nScale, -1.0*nScale); 125 | for (NSInteger idx = 0; idx < self.renderImage.size.height ; idx++) 126 | { 127 | NSInteger newIndex = idx + dropY*nFrame; 128 | if (newIndex>=targetFrame.origin.y) newIndex = targetFrame.origin.y; 129 | renderLeftUnit = (leftX[newIndex]-renderFrame.origin.x)/numFrames; 130 | rightBottom = CGPointMake(renderFrame.origin.x+renderFrame.size.width, renderFrame.origin.y+renderFrame.size.height); 131 | renderRightUnit = (rightBottom.x-rightX[newIndex])/numFrames; 132 | renderCurrentX = leftX[newIndex]; 133 | CGRect clipBox = CGRectMake(leftX[newIndex], renderFrame.origin.y+ idx*sliceHeight+ dropY*nFrame, 134 | rightX[newIndex]-leftX[newIndex], sliceHeight); 135 | CGContextSaveGState(bitmap); 136 | CGContextClipToRect(bitmap, clipBox); 137 | CGContextDrawImage(bitmap, clipBox, [[slices objectAtIndex:idx*nScale] CGImage]); 138 | CGContextRestoreGState(bitmap); 139 | } 140 | CGColorSpaceRelease(colorRGB); 141 | CGImageRef ref = CGBitmapContextCreateImage(bitmap); 142 | UIImage* result = [UIImage imageWithCGImage:ref scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp]; 143 | [allFrames addObject:result]; 144 | CGContextRelease(bitmap); 145 | CGImageRelease(ref); 146 | } 147 | 148 | reverseFrames = [[NSMutableArray alloc] initWithCapacity:allFrames.count]; 149 | for(nFrame=allFrames.count-1;nFrame>=0;nFrame--) 150 | { 151 | UIImage* aImage = [allFrames objectAtIndex:nFrame]; 152 | [reverseFrames addObject:aImage]; 153 | } 154 | } 155 | 156 | - (void)setRenderFrame:(CGRect)iRenderFrame andTargetFrame:(CGRect)iTargetFrame 157 | { 158 | // calculate the bezier path 159 | CGMutablePathRef pathRef = CGPathCreateMutable(); 160 | self.renderPath = pathRef; 161 | CGPathRetain(pathRef); 162 | renderFrame = iRenderFrame; 163 | targetFrame = iTargetFrame; 164 | allFrames = [[NSMutableArray alloc] initWithCapacity:15]; 165 | 166 | CGPoint rightTop, leftBottom, rightBottom; 167 | rightTop = CGPointMake(renderFrame.origin.x+renderFrame.size.width, renderFrame.origin.y); 168 | rightBottom = CGPointMake(renderFrame.origin.x+renderFrame.size.width, renderFrame.origin.y+renderFrame.size.height); 169 | leftBottom = CGPointMake(renderFrame.origin.x, renderFrame.origin.y+renderFrame.size.height); 170 | CGPoint targetRight = CGPointMake(targetFrame.origin.x+targetFrame.size.width, targetFrame.origin.y); 171 | 172 | 173 | CGPathMoveToPoint(pathRef, NULL, renderFrame.origin.x, renderFrame.origin.y); 174 | CGPathAddCurveToPoint(pathRef, NULL, 175 | targetFrame.origin.x*0.3, renderFrame.origin.y+renderFrame.size.height*0.6, 176 | targetFrame.origin.x*0.6, renderFrame.origin.y+renderFrame.size.height*0.3, 177 | targetFrame.origin.x+5, targetFrame.origin.y-5); 178 | CGPathAddLineToPoint(pathRef, NULL, targetRight.x-5,targetRight.y-5); 179 | CGPathAddCurveToPoint(pathRef, NULL, 180 | rightBottom.x*0.9, renderFrame.origin.y+renderFrame.size.height*0.3, 181 | rightBottom.x, renderFrame.origin.y+renderFrame.size.height*0.6, 182 | rightTop.x, rightTop.y); CGPathCloseSubpath(pathRef); 183 | 184 | [self setImageSlices]; 185 | 186 | float x, y; 187 | int nIndex; 188 | y=rightTop.y; 189 | for(nIndex=0; yleftX[nIndex]; x--) 204 | { 205 | if (CGPathContainsPoint(pathRef, NULL, CGPointMake(x, y), NO)) 206 | { 207 | rightX[nIndex] = x; 208 | break; 209 | } 210 | } 211 | if (x <= leftX[nIndex]) { 212 | rightX[nIndex] = leftX[nIndex]; 213 | } 214 | } 215 | 216 | [self setAnimationFrames]; 217 | 218 | 219 | } 220 | 221 | - (void)animationDone:(NSTimer*)timer 222 | { 223 | if (self.delegate) 224 | { 225 | [self.delegate geineAnimationDone]; 226 | } 227 | if (animationView) 228 | { 229 | [animationView removeFromSuperview]; 230 | animationView = nil; 231 | } 232 | isAnimation = NO; 233 | } 234 | 235 | - (void)genieAnimationShow:(bool)showing withDuration:(NSTimeInterval)duration 236 | { 237 | if (isAnimation) 238 | return; 239 | #if PROCESS_ANIMATION 240 | isAnimation = YES; 241 | animationView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, targetFrame.origin.y)]; 242 | 243 | NSArray *newImages; 244 | if (showing) 245 | { 246 | newImages = [NSArray arrayWithArray:reverseFrames]; 247 | } 248 | else 249 | { 250 | newImages = [NSArray arrayWithArray:allFrames]; 251 | } 252 | animationView.animationImages = newImages; 253 | animationView.animationDuration = duration; 254 | animationView.animationRepeatCount = 1; 255 | [animationView startAnimating]; 256 | [self addSubview:animationView]; 257 | 258 | doneTimer = [NSTimer scheduledTimerWithTimeInterval:duration target:self selector:@selector(animationDone:) userInfo:nil repeats:NO]; 259 | #else 260 | animationView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, targetFrame.origin.y)]; 261 | [animationView setImage:[allFrames objectAtIndex:AZANIMATION_FRAMERATE/2]]; 262 | [self addSubview:animationView]; 263 | #endif 264 | #if DRAW_PATH 265 | [self setNeedsDisplay]; 266 | #endif 267 | } 268 | 269 | @end 270 | -------------------------------------------------------------------------------- /GenieTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 839825F015E78D70002E01DE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 839825EF15E78D70002E01DE /* UIKit.framework */; }; 11 | 839825F215E78D70002E01DE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 839825F115E78D70002E01DE /* Foundation.framework */; }; 12 | 839825F415E78D70002E01DE /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 839825F315E78D70002E01DE /* CoreGraphics.framework */; }; 13 | 839825FA15E78D70002E01DE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 839825F815E78D70002E01DE /* InfoPlist.strings */; }; 14 | 839825FC15E78D70002E01DE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 839825FB15E78D70002E01DE /* main.m */; }; 15 | 8398260015E78D70002E01DE /* AZAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 839825FF15E78D70002E01DE /* AZAppDelegate.m */; }; 16 | 8398260315E78D70002E01DE /* AZViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8398260215E78D70002E01DE /* AZViewController.m */; }; 17 | 8398260615E78D70002E01DE /* AZViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8398260415E78D70002E01DE /* AZViewController.xib */; }; 18 | 8398260D15E78DF2002E01DE /* IMG_1623.JPG in Resources */ = {isa = PBXBuildFile; fileRef = 8398260C15E78DF2002E01DE /* IMG_1623.JPG */; }; 19 | 8398261015E78F91002E01DE /* AZGenieView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8398260F15E78F91002E01DE /* AZGenieView.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 839825EB15E78D70002E01DE /* GenieTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GenieTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 839825EF15E78D70002E01DE /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 25 | 839825F115E78D70002E01DE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 839825F315E78D70002E01DE /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 839825F715E78D70002E01DE /* GenieTest-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GenieTest-Info.plist"; sourceTree = ""; }; 28 | 839825F915E78D70002E01DE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 839825FB15E78D70002E01DE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 839825FD15E78D70002E01DE /* GenieTest-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GenieTest-Prefix.pch"; sourceTree = ""; }; 31 | 839825FE15E78D70002E01DE /* AZAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AZAppDelegate.h; sourceTree = ""; }; 32 | 839825FF15E78D70002E01DE /* AZAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AZAppDelegate.m; sourceTree = ""; }; 33 | 8398260115E78D70002E01DE /* AZViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AZViewController.h; sourceTree = ""; }; 34 | 8398260215E78D70002E01DE /* AZViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AZViewController.m; sourceTree = ""; }; 35 | 8398260515E78D70002E01DE /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/AZViewController.xib; sourceTree = ""; }; 36 | 8398260C15E78DF2002E01DE /* IMG_1623.JPG */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = IMG_1623.JPG; sourceTree = ""; }; 37 | 8398260E15E78F91002E01DE /* AZGenieView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AZGenieView.h; path = ../AZGenieView.h; sourceTree = ""; }; 38 | 8398260F15E78F91002E01DE /* AZGenieView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AZGenieView.m; path = ../AZGenieView.m; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 839825E815E78D70002E01DE /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | 839825F015E78D70002E01DE /* UIKit.framework in Frameworks */, 47 | 839825F215E78D70002E01DE /* Foundation.framework in Frameworks */, 48 | 839825F415E78D70002E01DE /* CoreGraphics.framework in Frameworks */, 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | /* End PBXFrameworksBuildPhase section */ 53 | 54 | /* Begin PBXGroup section */ 55 | 839825E015E78D70002E01DE = { 56 | isa = PBXGroup; 57 | children = ( 58 | 839825F515E78D70002E01DE /* GenieTest */, 59 | 839825EE15E78D70002E01DE /* Frameworks */, 60 | 839825EC15E78D70002E01DE /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 839825EC15E78D70002E01DE /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 839825EB15E78D70002E01DE /* GenieTest.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 839825EE15E78D70002E01DE /* Frameworks */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 839825EF15E78D70002E01DE /* UIKit.framework */, 76 | 839825F115E78D70002E01DE /* Foundation.framework */, 77 | 839825F315E78D70002E01DE /* CoreGraphics.framework */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | 839825F515E78D70002E01DE /* GenieTest */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 8398260E15E78F91002E01DE /* AZGenieView.h */, 86 | 8398260F15E78F91002E01DE /* AZGenieView.m */, 87 | 839825FE15E78D70002E01DE /* AZAppDelegate.h */, 88 | 839825FF15E78D70002E01DE /* AZAppDelegate.m */, 89 | 8398260115E78D70002E01DE /* AZViewController.h */, 90 | 8398260215E78D70002E01DE /* AZViewController.m */, 91 | 8398260415E78D70002E01DE /* AZViewController.xib */, 92 | 8398260C15E78DF2002E01DE /* IMG_1623.JPG */, 93 | 839825F615E78D70002E01DE /* Supporting Files */, 94 | ); 95 | path = GenieTest; 96 | sourceTree = ""; 97 | }; 98 | 839825F615E78D70002E01DE /* Supporting Files */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 839825F715E78D70002E01DE /* GenieTest-Info.plist */, 102 | 839825F815E78D70002E01DE /* InfoPlist.strings */, 103 | 839825FB15E78D70002E01DE /* main.m */, 104 | 839825FD15E78D70002E01DE /* GenieTest-Prefix.pch */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | /* End PBXGroup section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | 839825EA15E78D70002E01DE /* GenieTest */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = 8398260915E78D70002E01DE /* Build configuration list for PBXNativeTarget "GenieTest" */; 115 | buildPhases = ( 116 | 839825E715E78D70002E01DE /* Sources */, 117 | 839825E815E78D70002E01DE /* Frameworks */, 118 | 839825E915E78D70002E01DE /* Resources */, 119 | ); 120 | buildRules = ( 121 | ); 122 | dependencies = ( 123 | ); 124 | name = GenieTest; 125 | productName = GenieTest; 126 | productReference = 839825EB15E78D70002E01DE /* GenieTest.app */; 127 | productType = "com.apple.product-type.application"; 128 | }; 129 | /* End PBXNativeTarget section */ 130 | 131 | /* Begin PBXProject section */ 132 | 839825E215E78D70002E01DE /* Project object */ = { 133 | isa = PBXProject; 134 | attributes = { 135 | CLASSPREFIX = AZ; 136 | LastUpgradeCheck = 0440; 137 | ORGANIZATIONNAME = AuroraPlanet; 138 | }; 139 | buildConfigurationList = 839825E515E78D70002E01DE /* Build configuration list for PBXProject "GenieTest" */; 140 | compatibilityVersion = "Xcode 3.2"; 141 | developmentRegion = English; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | ); 146 | mainGroup = 839825E015E78D70002E01DE; 147 | productRefGroup = 839825EC15E78D70002E01DE /* Products */; 148 | projectDirPath = ""; 149 | projectRoot = ""; 150 | targets = ( 151 | 839825EA15E78D70002E01DE /* GenieTest */, 152 | ); 153 | }; 154 | /* End PBXProject section */ 155 | 156 | /* Begin PBXResourcesBuildPhase section */ 157 | 839825E915E78D70002E01DE /* Resources */ = { 158 | isa = PBXResourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | 839825FA15E78D70002E01DE /* InfoPlist.strings in Resources */, 162 | 8398260615E78D70002E01DE /* AZViewController.xib in Resources */, 163 | 8398260D15E78DF2002E01DE /* IMG_1623.JPG in Resources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXResourcesBuildPhase section */ 168 | 169 | /* Begin PBXSourcesBuildPhase section */ 170 | 839825E715E78D70002E01DE /* Sources */ = { 171 | isa = PBXSourcesBuildPhase; 172 | buildActionMask = 2147483647; 173 | files = ( 174 | 839825FC15E78D70002E01DE /* main.m in Sources */, 175 | 8398260015E78D70002E01DE /* AZAppDelegate.m in Sources */, 176 | 8398260315E78D70002E01DE /* AZViewController.m in Sources */, 177 | 8398261015E78F91002E01DE /* AZGenieView.m in Sources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXSourcesBuildPhase section */ 182 | 183 | /* Begin PBXVariantGroup section */ 184 | 839825F815E78D70002E01DE /* InfoPlist.strings */ = { 185 | isa = PBXVariantGroup; 186 | children = ( 187 | 839825F915E78D70002E01DE /* en */, 188 | ); 189 | name = InfoPlist.strings; 190 | sourceTree = ""; 191 | }; 192 | 8398260415E78D70002E01DE /* AZViewController.xib */ = { 193 | isa = PBXVariantGroup; 194 | children = ( 195 | 8398260515E78D70002E01DE /* en */, 196 | ); 197 | name = AZViewController.xib; 198 | sourceTree = ""; 199 | }; 200 | /* End PBXVariantGroup section */ 201 | 202 | /* Begin XCBuildConfiguration section */ 203 | 8398260715E78D70002E01DE /* Debug */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 208 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 209 | CLANG_ENABLE_OBJC_ARC = YES; 210 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 211 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 212 | COPY_PHASE_STRIP = NO; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_OPTIMIZATION_LEVEL = 0; 216 | GCC_PREPROCESSOR_DEFINITIONS = ( 217 | "DEBUG=1", 218 | "$(inherited)", 219 | ); 220 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 221 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 223 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 226 | SDKROOT = iphoneos; 227 | }; 228 | name = Debug; 229 | }; 230 | 8398260815E78D70002E01DE /* Release */ = { 231 | isa = XCBuildConfiguration; 232 | buildSettings = { 233 | ALWAYS_SEARCH_USER_PATHS = NO; 234 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 238 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 239 | COPY_PHASE_STRIP = YES; 240 | GCC_C_LANGUAGE_STANDARD = gnu99; 241 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 242 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 243 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 244 | GCC_WARN_UNUSED_VARIABLE = YES; 245 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 246 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 247 | SDKROOT = iphoneos; 248 | VALIDATE_PRODUCT = YES; 249 | }; 250 | name = Release; 251 | }; 252 | 8398260A15E78D70002E01DE /* Debug */ = { 253 | isa = XCBuildConfiguration; 254 | buildSettings = { 255 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 256 | GCC_PREFIX_HEADER = "GenieTest/GenieTest-Prefix.pch"; 257 | INFOPLIST_FILE = "GenieTest/GenieTest-Info.plist"; 258 | PRODUCT_NAME = "$(TARGET_NAME)"; 259 | WRAPPER_EXTENSION = app; 260 | }; 261 | name = Debug; 262 | }; 263 | 8398260B15E78D70002E01DE /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 267 | GCC_PREFIX_HEADER = "GenieTest/GenieTest-Prefix.pch"; 268 | INFOPLIST_FILE = "GenieTest/GenieTest-Info.plist"; 269 | PRODUCT_NAME = "$(TARGET_NAME)"; 270 | WRAPPER_EXTENSION = app; 271 | }; 272 | name = Release; 273 | }; 274 | /* End XCBuildConfiguration section */ 275 | 276 | /* Begin XCConfigurationList section */ 277 | 839825E515E78D70002E01DE /* Build configuration list for PBXProject "GenieTest" */ = { 278 | isa = XCConfigurationList; 279 | buildConfigurations = ( 280 | 8398260715E78D70002E01DE /* Debug */, 281 | 8398260815E78D70002E01DE /* Release */, 282 | ); 283 | defaultConfigurationIsVisible = 0; 284 | defaultConfigurationName = Release; 285 | }; 286 | 8398260915E78D70002E01DE /* Build configuration list for PBXNativeTarget "GenieTest" */ = { 287 | isa = XCConfigurationList; 288 | buildConfigurations = ( 289 | 8398260A15E78D70002E01DE /* Debug */, 290 | 8398260B15E78D70002E01DE /* Release */, 291 | ); 292 | defaultConfigurationIsVisible = 0; 293 | }; 294 | /* End XCConfigurationList section */ 295 | }; 296 | rootObject = 839825E215E78D70002E01DE /* Project object */; 297 | } 298 | -------------------------------------------------------------------------------- /GenieTest/AZAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AZAppDelegate.h 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class AZViewController; 12 | 13 | @interface AZAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) AZViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /GenieTest/AZAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AZAppDelegate.m 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import "AZAppDelegate.h" 10 | 11 | #import "AZViewController.h" 12 | 13 | @implementation AZAppDelegate 14 | 15 | @synthesize window = _window; 16 | @synthesize viewController; 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 19 | { 20 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 21 | // Override point for customization after application launch. 22 | self.viewController = [[AZViewController alloc] initWithNibName:@"AZViewController" bundle:nil]; 23 | self.window.rootViewController = self.viewController; 24 | [self.window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application 29 | { 30 | // 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. 31 | // 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. 32 | } 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application 35 | { 36 | // 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. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application 41 | { 42 | // 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. 43 | } 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application 46 | { 47 | // 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. 48 | } 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application 51 | { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /GenieTest/AZViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // AZViewController.h 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AZGenieView.h" 11 | 12 | @interface AZViewController : UIViewController 13 | @property (strong, nonatomic) IBOutlet AZGenieView *genieView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GenieTest/AZViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // AZViewController.m 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AZViewController.h" 11 | 12 | @interface AZViewController () 13 | 14 | @property (assign, nonatomic) bool isShow; 15 | @property (weak, nonatomic) IBOutlet UIImageView *flowerView; 16 | @property (weak, nonatomic) IBOutlet UIButton *targetButton; 17 | - (IBAction)doClick:(id)sender; 18 | 19 | @end 20 | 21 | @implementation AZViewController 22 | @synthesize genieView; 23 | @synthesize flowerView; 24 | @synthesize targetButton; 25 | @synthesize isShow; 26 | 27 | - (void)viewDidLoad 28 | { 29 | [super viewDidLoad]; 30 | self.isShow = YES; 31 | UIImage *screenshot = [self screenshotForViewController]; 32 | [self.genieView setDelegate:self]; 33 | self.genieView.renderImage = screenshot; 34 | [self.genieView setRenderFrame:self.flowerView.frame andTargetFrame:self.targetButton.frame]; 35 | // Do any additional setup after loading the view, typically from a nib. 36 | } 37 | 38 | - (void)viewDidUnload 39 | { 40 | [self setFlowerView:nil]; 41 | [self setTargetButton:nil]; 42 | [self setGenieView:nil]; 43 | [super viewDidUnload]; 44 | // Release any retained subviews of the main view. 45 | } 46 | 47 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 48 | { 49 | return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 50 | } 51 | 52 | - (UIImage *)screenshotForViewController 53 | { 54 | UIGraphicsBeginImageContextWithOptions(self.flowerView.bounds.size, YES, [[UIScreen mainScreen] scale]); 55 | [self.flowerView.layer renderInContext:UIGraphicsGetCurrentContext()]; 56 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 57 | return image; 58 | } 59 | 60 | - (void)geineAnimationDone 61 | { 62 | if (self.isShow) 63 | self.flowerView.hidden = NO; 64 | } 65 | 66 | - (IBAction)doClick:(id)sender { 67 | self.isShow = !self.isShow; 68 | if (!self.isShow) 69 | self.flowerView.hidden = YES; 70 | [self.genieView genieAnimationShow:self.isShow withDuration:1]; 71 | } 72 | @end 73 | -------------------------------------------------------------------------------- /GenieTest/GenieTest-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.auroraplanet.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /GenieTest/GenieTest-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'GenieTest' target in the 'GenieTest' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /GenieTest/IMG_1623.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/godrm/AZGenieView/a46dc0797fee1c04b99500c7389fb4fa2d68aee5/GenieTest/IMG_1623.JPG -------------------------------------------------------------------------------- /GenieTest/en.lproj/AZViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1296 5 | 12B19 6 | 2549 7 | 1187 8 | 624.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 1498 12 | 13 | 14 | IBProxyObject 15 | IBUIButton 16 | IBUIImageView 17 | IBUIView 18 | 19 | 20 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 21 | 22 | 23 | PluginDependencyRecalculationVersion 24 | 25 | 26 | 27 | 28 | IBFilesOwner 29 | IBCocoaTouchFramework 30 | 31 | 32 | IBFirstResponder 33 | IBCocoaTouchFramework 34 | 35 | 36 | 37 | 274 38 | 39 | 40 | 41 | 292 42 | {{28, 124}, {225, 196}} 43 | 44 | 45 | 46 | _NS:9 47 | NO 48 | IBCocoaTouchFramework 49 | 50 | NSImage 51 | IMG_1623.JPG 52 | 53 | 54 | 55 | 56 | 292 57 | {{251, 403}, {49, 37}} 58 | 59 | 60 | _NS:9 61 | NO 62 | IBCocoaTouchFramework 63 | 0 64 | 0 65 | 1 66 | DO 67 | 68 | 3 69 | MQA 70 | 71 | 72 | 1 73 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 74 | 75 | 76 | 3 77 | MC41AA 78 | 79 | 80 | 2 81 | 15 82 | 83 | 84 | Helvetica-Bold 85 | 15 86 | 16 87 | 88 | 89 | 90 | {{0, 20}, {320, 460}} 91 | 92 | 93 | 94 | 95 | 3 96 | MC43NQA 97 | 98 | 2 99 | 100 | 101 | NO 102 | 103 | IBCocoaTouchFramework 104 | 105 | 106 | 107 | 108 | 109 | 110 | view 111 | 112 | 113 | 114 | 7 115 | 116 | 117 | 118 | flowerView 119 | 120 | 121 | 122 | 11 123 | 124 | 125 | 126 | targetButton 127 | 128 | 129 | 130 | 12 131 | 132 | 133 | 134 | genieView 135 | 136 | 137 | 138 | 14 139 | 140 | 141 | 142 | doClick: 143 | 144 | 145 | 7 146 | 147 | 13 148 | 149 | 150 | 151 | 152 | 153 | 0 154 | 155 | 156 | 157 | 158 | 159 | -1 160 | 161 | 162 | File's Owner 163 | 164 | 165 | -2 166 | 167 | 168 | 169 | 170 | 6 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 8 180 | 181 | 182 | 183 | 184 | 9 185 | 186 | 187 | 188 | 189 | 190 | 191 | AZViewController 192 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 193 | UIResponder 194 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 195 | AZGenieView 196 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 197 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 198 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 199 | 200 | 201 | 202 | 203 | 204 | 14 205 | 206 | 207 | 208 | 209 | AZGenieView 210 | UIView 211 | 212 | IBProjectSource 213 | ./Classes/AZGenieView.h 214 | 215 | 216 | 217 | AZViewController 218 | UIViewController 219 | 220 | doClick: 221 | id 222 | 223 | 224 | doClick: 225 | 226 | doClick: 227 | id 228 | 229 | 230 | 231 | UIImageView 232 | AZGenieView 233 | UIButton 234 | 235 | 236 | 237 | flowerView 238 | UIImageView 239 | 240 | 241 | genieView 242 | AZGenieView 243 | 244 | 245 | targetButton 246 | UIButton 247 | 248 | 249 | 250 | IBProjectSource 251 | ./Classes/AZViewController.h 252 | 253 | 254 | 255 | 256 | 0 257 | IBCocoaTouchFramework 258 | 259 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 260 | 261 | 262 | YES 263 | 3 264 | 265 | IMG_1623.JPG 266 | {1024, 683} 267 | 268 | 1498 269 | 270 | 271 | -------------------------------------------------------------------------------- /GenieTest/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GenieTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // GenieTest 4 | // 5 | // Created by Jung Kim on 12. 8. 24.. 6 | // Copyright (c) 2012년 AuroraPlanet. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AZAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AZAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | AZGenieView 2 | =========== 3 | 4 | Genie animation effect for iOS UIView --------------------------------------------------------------------------------