├── .gitignore ├── A-Parallax ├── A_Parallax.h ├── A_ParallaxManager.h ├── A_ParallaxManager.m ├── UIView+A_Parallax.h ├── UIView+A_Parallax.m ├── UIViewController+A_Parallax.h └── UIViewController+A_Parallax.m ├── A-ParallaxDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── A-ParallaxDemo ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── backgroup.imageset │ │ ├── Contents.json │ │ └── backgroup.jpg ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── README.md └── demoGif └── demo.gif /.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 | -------------------------------------------------------------------------------- /A-Parallax/A_Parallax.h: -------------------------------------------------------------------------------- 1 | // 2 | // A_Parallax.h 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 9/7/15. 6 | // Copyright © 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #ifndef A_Parallax_h 10 | #define A_Parallax_h 11 | 12 | #import "A_ParallaxManager.h" 13 | #import "UIViewController+A_Parallax.h" 14 | #import "UIView+A_Parallax.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /A-Parallax/A_ParallaxManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // A_ParallaxManager.h 3 | // A-Parallax 4 | // 5 | // Created by Animax Deng on 8/19/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define A_Parallax_displacementRange 0.3f 12 | 13 | @interface A_ParallaxManager : NSObject 14 | 15 | // the maximum offset of shadow, default: 5.0f 16 | @property (nonatomic) CGFloat shadowDynamicOffset; 17 | // the fixed offset of shadow, default: (1, 3) 18 | @property (nonatomic) CGPoint shadowFixedOffset; 19 | // the shadow radius, default: 5.0f 20 | @property (nonatomic) CGFloat shadowRadius; 21 | // the shadow opacity, default: 0.8f 22 | @property (nonatomic) CGFloat shadowOpacity; 23 | // the shadow color, default: blackColor 24 | @property (nonatomic) UIColor *shadowColor; 25 | 26 | + (A_ParallaxManager *)shareInstance; 27 | 28 | - (void)storeBackgroundView:(UIView*)view; 29 | 30 | // depth is about how depth the view should be, range shallower [0...1] deeper 31 | - (void)storeView:(UIView*)view depth:(CGFloat)depth andShadow:(BOOL)enable; 32 | - (void)storeView:(UIView*)view depth:(CGFloat)depth; 33 | - (void)storeView:(UIView*)view shadow:(BOOL)enable; 34 | 35 | - (BOOL)removeView:(UIView*)view; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /A-Parallax/A_ParallaxManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // A_ParallaxManager.m 3 | // A-Parallax 4 | // 5 | // Created by Animax Deng on 8/19/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "A_ParallaxManager.h" 10 | #import 11 | 12 | #define A_Parallax_updateInterval 0.1f 13 | #define A_Parallax_animationSetpsNumber 6 14 | #define A_Parallax_BackgroundFixedHorizentalOffsetRate 0.15 15 | 16 | #pragma mark - Parallax View Model 17 | @interface A_ParallaxViewModel : NSObject 18 | 19 | @property (nonatomic) CGFloat depth; 20 | @property (weak, nonatomic) UIView *view; 21 | @property (nonatomic) CGPoint originalCenterPoint; 22 | 23 | @property (nonatomic) CGPoint stepDistance; 24 | @property (nonatomic) int remainSteps; 25 | 26 | @property (nonatomic) BOOL isBackgroundView; 27 | @property (nonatomic) BOOL enableShadow; 28 | 29 | @end 30 | 31 | @implementation A_ParallaxViewModel 32 | 33 | - (instancetype)initWithView:(UIView *)view andShadow:(BOOL)enable { 34 | self = [super init]; 35 | if (self) { 36 | self.view = view; 37 | self.originalCenterPoint = view.center; 38 | self.isBackgroundView = NO; 39 | self.enableShadow = enable; 40 | if (self.depth == .0f) { 41 | self.depth = .5f; 42 | } 43 | } 44 | return self; 45 | } 46 | - (instancetype)initWithView:(UIView *)view andDepth:(CGFloat)depth { 47 | self = [super init]; 48 | if (self) { 49 | self.view = view; 50 | self.originalCenterPoint = view.center; 51 | self.isBackgroundView = NO; 52 | 53 | if (depth < 0.0f) { 54 | self.depth = 0.0f; 55 | } else if (depth > 1.0f) { 56 | self.depth = 1.0f; 57 | } else { 58 | self.depth = depth; 59 | } 60 | 61 | } 62 | return self; 63 | } 64 | 65 | - (void)moveToNextStep:(CMDeviceMotion *)motion { 66 | A_ParallaxManager *manager = [A_ParallaxManager shareInstance]; 67 | 68 | CGPoint currentViewCenter = _view.center; 69 | 70 | // animation steps 71 | if (_remainSteps > 0){ 72 | _remainSteps--; 73 | } else { 74 | // calculate new animation distination 75 | CGPoint destinationPoint = [self calculateDestinationPoint:motion]; 76 | _stepDistance = CGPointMake((destinationPoint.x-currentViewCenter.x) / A_Parallax_animationSetpsNumber, 77 | (destinationPoint.y-currentViewCenter.y) / A_Parallax_animationSetpsNumber); 78 | 79 | _remainSteps = A_Parallax_animationSetpsNumber; 80 | } 81 | 82 | // move to next step position 83 | CGPoint newPoint = CGPointMake(currentViewCenter.x + _stepDistance.x, currentViewCenter.y + _stepDistance.y); 84 | 85 | 86 | [self.view setCenter:newPoint]; 87 | 88 | // draw the shadow 89 | if (self.enableShadow) { 90 | self.view.layer.shadowColor = manager.shadowColor.CGColor; 91 | self.view.layer.masksToBounds = NO; 92 | CGSize shadowOffset = CGSizeMake(motion.gravity.x * manager.shadowDynamicOffset + (manager.shadowFixedOffset.x), 93 | motion.gravity.y * manager.shadowDynamicOffset * -1 + (manager.shadowFixedOffset.y)); 94 | self.view.layer.shadowOffset = shadowOffset; 95 | self.view.layer.shadowRadius = manager.shadowRadius; 96 | self.view.layer.shadowOpacity = manager.shadowOpacity; 97 | } else { 98 | self.view.layer.shadowOpacity = 0.0f; 99 | } 100 | } 101 | 102 | - (CGPoint)calculateDestinationPoint:(CMDeviceMotion *)data { 103 | CGSize viewSize = self.view.frame.size; 104 | 105 | if (self.isBackgroundView) { 106 | return CGPointMake(_originalCenterPoint.x + (_originalCenterPoint.x * data.gravity.x * A_Parallax_displacementRange) * -1, 107 | _originalCenterPoint.y + (_originalCenterPoint.y * data.gravity.y * A_Parallax_displacementRange) + (_originalCenterPoint.y * A_Parallax_BackgroundFixedHorizentalOffsetRate)); 108 | } else { 109 | return CGPointMake(_originalCenterPoint.x + ((viewSize.width * data.gravity.x * A_Parallax_displacementRange) * self.depth), 110 | _originalCenterPoint.y + ((viewSize.height * data.gravity.y * A_Parallax_displacementRange) * self.depth)); 111 | } 112 | } 113 | 114 | @end 115 | 116 | 117 | #pragma mark - Parallax Manager 118 | @implementation A_ParallaxManager { 119 | CMMotionManager *_motionManager; 120 | NSMutableArray *_subviewModels; 121 | NSMutableArray *_emptyViewModels; 122 | 123 | CADisplayLink *_displayLink; 124 | } 125 | 126 | + (A_ParallaxManager *)shareInstance { 127 | static dispatch_once_t pred = 0; 128 | __strong static A_ParallaxManager *_manager = nil; 129 | dispatch_once(&pred, ^{ 130 | _manager = [[A_ParallaxManager alloc] initManager]; 131 | }); 132 | 133 | return _manager; 134 | } 135 | 136 | - (instancetype)init { 137 | self = [super init]; 138 | if (self) { 139 | [NSException raise:NSInternalInconsistencyException format:@"Please use shareInstance to get the instance"]; 140 | } 141 | return self; 142 | } 143 | - (instancetype)initManager { 144 | self = [super init]; 145 | if (self) { 146 | _subviewModels = [[NSMutableArray alloc] init]; 147 | _emptyViewModels = [[NSMutableArray alloc] init]; 148 | _motionManager = [[CMMotionManager alloc] init]; 149 | 150 | // set the default params 151 | _shadowDynamicOffset = 5.0f; 152 | _shadowFixedOffset = CGPointMake(1.0f, 3.0f); 153 | _shadowRadius = 5.0f; 154 | _shadowOpacity = 0.8f; 155 | _shadowColor = [UIColor blackColor]; 156 | 157 | if (_motionManager.deviceMotionAvailable) { 158 | _motionManager.deviceMotionUpdateInterval = A_Parallax_updateInterval; 159 | [_motionManager startDeviceMotionUpdates]; 160 | 161 | _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkHandler)]; 162 | _displayLink.frameInterval = 1; 163 | 164 | [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; 165 | } 166 | } 167 | return self; 168 | } 169 | - (void)displayLinkHandler { 170 | CMDeviceMotion *motion = _motionManager.deviceMotion; 171 | if (motion) { 172 | @synchronized(self) { 173 | for (A_ParallaxViewModel *model in _subviewModels) { 174 | if (model.view) { 175 | [model moveToNextStep:motion]; 176 | } 177 | } 178 | } 179 | } 180 | } 181 | 182 | - (void)storeBackgroundView:(UIView*)view { 183 | @synchronized(self) { 184 | A_ParallaxViewModel *model = [self getParallaxModel:view]; 185 | 186 | if (!model) { 187 | model = [[A_ParallaxViewModel alloc] initWithView:view andDepth:1.0f]; 188 | [_subviewModels addObject:model]; 189 | } 190 | 191 | model.depth = 1.0f; 192 | model.isBackgroundView = YES; 193 | } 194 | } 195 | - (void)storeView:(UIView*)view depth:(CGFloat)depth andShadow:(BOOL)enable { 196 | @synchronized(self) { 197 | A_ParallaxViewModel *model = [self getParallaxModel:view]; 198 | if (!model) { 199 | model = [[A_ParallaxViewModel alloc] initWithView:view andDepth:depth]; 200 | model.enableShadow = enable; 201 | [_subviewModels addObject:model]; 202 | } else { 203 | model.depth = depth; 204 | model.enableShadow = enable; 205 | } 206 | model.isBackgroundView = NO; 207 | } 208 | } 209 | - (void)storeView:(UIView*)view depth:(CGFloat)depth { 210 | @synchronized(self) { 211 | A_ParallaxViewModel *model = [self getParallaxModel:view]; 212 | if (!model) { 213 | model = [[A_ParallaxViewModel alloc] initWithView:view andDepth:depth]; 214 | [_subviewModels addObject:model]; 215 | } else { 216 | model.depth = depth; 217 | } 218 | model.isBackgroundView = NO; 219 | } 220 | } 221 | - (void)storeView:(UIView*)view shadow:(BOOL)enable { 222 | @synchronized(self) { 223 | A_ParallaxViewModel *model = [self getParallaxModel:view]; 224 | if (!model) { 225 | model = [[A_ParallaxViewModel alloc] initWithView:view andShadow:enable]; 226 | [_subviewModels addObject:model]; 227 | } else { 228 | model.enableShadow = enable; 229 | } 230 | model.isBackgroundView = NO; 231 | } 232 | } 233 | 234 | - (A_ParallaxViewModel *)getParallaxModel:(UIView *)view { 235 | A_ParallaxViewModel *model = nil; 236 | for (A_ParallaxViewModel *item in _subviewModels) { 237 | if (!item.view) { 238 | [_emptyViewModels addObject:item]; 239 | } else if (item.view == view) { 240 | model = item; 241 | } 242 | } 243 | 244 | for (A_ParallaxViewModel *item in _emptyViewModels) { 245 | [_subviewModels removeObject:item]; 246 | } 247 | 248 | return model; 249 | } 250 | 251 | - (BOOL)removeView:(UIView*)view { 252 | @synchronized(self) { 253 | for (A_ParallaxViewModel *item in _subviewModels) { 254 | if (item.view == view) { 255 | [view setCenter:item.originalCenterPoint]; 256 | [_subviewModels removeObject:item]; 257 | return YES; 258 | } 259 | } 260 | return NO; 261 | } 262 | } 263 | 264 | #pragma mark - Helping methods 265 | - (CGFloat)degreesToRadians:(CGFloat) degrees { 266 | return degrees * M_PI / 180; 267 | }; 268 | - (CGFloat)radiansToDegrees:(CGFloat) radians { 269 | return radians * 180 / M_PI; 270 | }; 271 | 272 | @end 273 | 274 | 275 | 276 | 277 | 278 | -------------------------------------------------------------------------------- /A-Parallax/UIView+A_Parallax.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+A_Parallax.h 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/26/15. 6 | // Copyright © 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (A_Parallax) 12 | 13 | - (void)A_SetParallax; 14 | - (void)A_SetParallaxDepth: (CGFloat)depth; 15 | - (void)A_SetParallaxShadow: (BOOL)enable; 16 | - (void)A_SetParallaxDepth: (CGFloat)depth andShadow: (BOOL)enable; 17 | 18 | - (void)A_DeleteParallax; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /A-Parallax/UIView+A_Parallax.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+A_Parallax.m 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/26/15. 6 | // Copyright © 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "UIView+A_Parallax.h" 10 | #import "A_ParallaxManager.h" 11 | 12 | @implementation UIView (A_Parallax) 13 | 14 | - (void)A_SetParallax { 15 | [[A_ParallaxManager shareInstance] storeView:self shadow:YES]; 16 | } 17 | - (void)A_SetParallaxDepth: (CGFloat)depth { 18 | [[A_ParallaxManager shareInstance] storeView:self depth:depth]; 19 | } 20 | - (void)A_SetParallaxShadow: (BOOL)enable { 21 | [[A_ParallaxManager shareInstance] storeView:self shadow:enable]; 22 | } 23 | - (void)A_SetParallaxDepth: (CGFloat)depth andShadow: (BOOL)enable { 24 | [[A_ParallaxManager shareInstance] storeView:self depth:depth andShadow:enable]; 25 | } 26 | 27 | - (void)A_DeleteParallax { 28 | [[A_ParallaxManager shareInstance] removeView:self]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /A-Parallax/UIViewController+A_Parallax.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+A_Parallax.h 3 | // A-Parallax 4 | // 5 | // Created by Animax Deng on 8/19/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_OPTIONS(NSUInteger, A_ParallaxBackgoundDisplayEffect) { 12 | A_ParallaxBackgoundDisplayEffectWithNoEffection = 0, 13 | A_ParallaxBackgoundDisplayEffectWithOpacity = 1 << 1, 14 | A_ParallaxBackgoundDisplayEffectWithTransform = 1 << 2, 15 | }; 16 | 17 | @interface UIViewController (A_Parallax) 18 | 19 | - (void)A_ParallaxBackground: (UIImage *)image; 20 | - (void)A_ParallaxBackground: (UIImage *)image withEffect:(A_ParallaxBackgoundDisplayEffect)effects; 21 | 22 | - (void)A_DeleteParallaxBackgound:(BOOL)animation; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /A-Parallax/UIViewController+A_Parallax.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+A_Parallax.m 3 | // A-Parallax 4 | // 5 | // Created by Animax Deng on 8/19/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+A_Parallax.h" 10 | #import "A_ParallaxManager.h" 11 | #import 12 | 13 | @implementation UIViewController (A_Parallax) 14 | 15 | static char _parallaxBackgroupViewKey; 16 | 17 | - (void)A_ParallaxBackground: (UIImage *)image { 18 | [self A_ParallaxBackground:image withEffect:A_ParallaxBackgoundDisplayEffectWithNoEffection]; 19 | } 20 | - (void)A_ParallaxBackground: (UIImage *)image withEffect:(A_ParallaxBackgoundDisplayEffect)effects { 21 | UIImageView *backgroupView = objc_getAssociatedObject(self, &_parallaxBackgroupViewKey); 22 | if (backgroupView) { 23 | [backgroupView removeFromSuperview]; 24 | [[A_ParallaxManager shareInstance] removeView:backgroupView]; 25 | } 26 | 27 | backgroupView = [[UIImageView alloc] initWithImage:image]; 28 | CGRect viewFrame = backgroupView.frame; 29 | viewFrame.origin.x -= self.view.bounds.size.width * (A_Parallax_displacementRange * 0.5); 30 | viewFrame.origin.y -= self.view.bounds.size.height * (A_Parallax_displacementRange * 0.5); 31 | viewFrame.size.height = self.view.bounds.size.height * (1 + (A_Parallax_displacementRange)); 32 | viewFrame.size.width = self.view.bounds.size.width * (1 + (A_Parallax_displacementRange)); 33 | backgroupView.frame = viewFrame; 34 | [backgroupView setContentMode:UIViewContentModeScaleAspectFill]; 35 | 36 | [self.view insertSubview:backgroupView atIndex:0]; 37 | 38 | // displaying animation 39 | if (effects == A_ParallaxBackgoundDisplayEffectWithNoEffection) { 40 | [[A_ParallaxManager shareInstance] storeBackgroundView:backgroupView]; 41 | } else { 42 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 43 | [animationGroup setRemovedOnCompletion: YES]; 44 | animationGroup.duration = 0.3f; 45 | 46 | NSMutableArray *animationEffects = [[NSMutableArray alloc] init]; 47 | 48 | if (effects & A_ParallaxBackgoundDisplayEffectWithOpacity) { 49 | CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; 50 | opacityAnimation.fromValue = @(0.0f); 51 | opacityAnimation.toValue = @(1.0f); 52 | [animationEffects addObject:opacityAnimation]; 53 | } 54 | 55 | if (effects & A_ParallaxBackgoundDisplayEffectWithTransform) { 56 | CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"]; 57 | transformAnimation.timingFunction = [[CAMediaTimingFunction alloc] initWithControlPoints:.5 :1.5 :1 :1]; 58 | transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.6, 1.6, 1)]; 59 | transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1)]; 60 | [animationEffects addObject:transformAnimation]; 61 | } 62 | 63 | animationGroup.animations = animationEffects; 64 | 65 | [CATransaction begin]; { 66 | [CATransaction setCompletionBlock:^{ 67 | [[A_ParallaxManager shareInstance] storeBackgroundView:backgroupView]; 68 | }]; 69 | [backgroupView.layer addAnimation:animationGroup forKey:nil]; 70 | } [CATransaction commit]; 71 | } 72 | objc_setAssociatedObject(self, &_parallaxBackgroupViewKey, backgroupView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 73 | } 74 | 75 | - (void)A_DeleteParallaxBackgound:(BOOL)animation { 76 | UIImageView *backgroupView = objc_getAssociatedObject(self, &_parallaxBackgroupViewKey); 77 | if (backgroupView) { 78 | if (animation) { 79 | [UIView animateWithDuration:0.5f animations:^{ 80 | [backgroupView setAlpha:0.0f]; 81 | } completion:^(BOOL finished) { 82 | [[A_ParallaxManager shareInstance] removeView:backgroupView]; 83 | [backgroupView setImage:nil]; 84 | }]; 85 | } else { 86 | [[A_ParallaxManager shareInstance] removeView:backgroupView]; 87 | [backgroupView setImage:nil]; 88 | } 89 | } 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /A-ParallaxDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6939F4211B8E899B00CBCC8C /* UIView+A_Parallax.m in Sources */ = {isa = PBXBuildFile; fileRef = 6939F4201B8E899B00CBCC8C /* UIView+A_Parallax.m */; }; 11 | 695E92B61B86CA5C00C7D40B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 695E92B51B86CA5C00C7D40B /* main.m */; }; 12 | 695E92B91B86CA5C00C7D40B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 695E92B81B86CA5C00C7D40B /* AppDelegate.m */; }; 13 | 695E92BC1B86CA5C00C7D40B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 695E92BB1B86CA5C00C7D40B /* ViewController.m */; }; 14 | 695E92BF1B86CA5C00C7D40B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 695E92BD1B86CA5C00C7D40B /* Main.storyboard */; }; 15 | 695E92C11B86CA5C00C7D40B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 695E92C01B86CA5C00C7D40B /* Images.xcassets */; }; 16 | 695E92C41B86CA5C00C7D40B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 695E92C21B86CA5C00C7D40B /* LaunchScreen.xib */; }; 17 | 695E92DE1B86D09300C7D40B /* A_ParallaxManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 695E92DB1B86D09300C7D40B /* A_ParallaxManager.m */; }; 18 | 695E92DF1B86D09300C7D40B /* UIViewController+A_Parallax.m in Sources */ = {isa = PBXBuildFile; fileRef = 695E92DD1B86D09300C7D40B /* UIViewController+A_Parallax.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 6929C9631B9E3EC600141AB2 /* A_Parallax.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = A_Parallax.h; sourceTree = ""; }; 23 | 6939F41F1B8E899B00CBCC8C /* UIView+A_Parallax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+A_Parallax.h"; sourceTree = ""; }; 24 | 6939F4201B8E899B00CBCC8C /* UIView+A_Parallax.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+A_Parallax.m"; sourceTree = ""; }; 25 | 695E92B01B86CA5C00C7D40B /* A-ParallaxDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "A-ParallaxDemo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 695E92B41B86CA5C00C7D40B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 695E92B51B86CA5C00C7D40B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 28 | 695E92B71B86CA5C00C7D40B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 29 | 695E92B81B86CA5C00C7D40B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 30 | 695E92BA1B86CA5C00C7D40B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 31 | 695E92BB1B86CA5C00C7D40B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 32 | 695E92BE1B86CA5C00C7D40B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 33 | 695E92C01B86CA5C00C7D40B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 34 | 695E92C31B86CA5C00C7D40B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 35 | 695E92DA1B86D09300C7D40B /* A_ParallaxManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = A_ParallaxManager.h; sourceTree = ""; }; 36 | 695E92DB1B86D09300C7D40B /* A_ParallaxManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = A_ParallaxManager.m; sourceTree = ""; }; 37 | 695E92DC1B86D09300C7D40B /* UIViewController+A_Parallax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+A_Parallax.h"; sourceTree = ""; }; 38 | 695E92DD1B86D09300C7D40B /* UIViewController+A_Parallax.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+A_Parallax.m"; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 695E92AD1B86CA5C00C7D40B /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 695E92A71B86CA5C00C7D40B = { 53 | isa = PBXGroup; 54 | children = ( 55 | 695E92B21B86CA5C00C7D40B /* A-ParallaxDemo */, 56 | 695E92D91B86D09300C7D40B /* A-Parallax */, 57 | 695E92B11B86CA5C00C7D40B /* Products */, 58 | ); 59 | sourceTree = ""; 60 | }; 61 | 695E92B11B86CA5C00C7D40B /* Products */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 695E92B01B86CA5C00C7D40B /* A-ParallaxDemo.app */, 65 | ); 66 | name = Products; 67 | sourceTree = ""; 68 | }; 69 | 695E92B21B86CA5C00C7D40B /* A-ParallaxDemo */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 695E92B71B86CA5C00C7D40B /* AppDelegate.h */, 73 | 695E92B81B86CA5C00C7D40B /* AppDelegate.m */, 74 | 695E92BA1B86CA5C00C7D40B /* ViewController.h */, 75 | 695E92BB1B86CA5C00C7D40B /* ViewController.m */, 76 | 695E92BD1B86CA5C00C7D40B /* Main.storyboard */, 77 | 695E92C21B86CA5C00C7D40B /* LaunchScreen.xib */, 78 | 695E92C01B86CA5C00C7D40B /* Images.xcassets */, 79 | 695E92B31B86CA5C00C7D40B /* Supporting Files */, 80 | ); 81 | path = "A-ParallaxDemo"; 82 | sourceTree = ""; 83 | }; 84 | 695E92B31B86CA5C00C7D40B /* Supporting Files */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 695E92B41B86CA5C00C7D40B /* Info.plist */, 88 | 695E92B51B86CA5C00C7D40B /* main.m */, 89 | ); 90 | name = "Supporting Files"; 91 | sourceTree = ""; 92 | }; 93 | 695E92D91B86D09300C7D40B /* A-Parallax */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 695E92DA1B86D09300C7D40B /* A_ParallaxManager.h */, 97 | 695E92DB1B86D09300C7D40B /* A_ParallaxManager.m */, 98 | 695E92DC1B86D09300C7D40B /* UIViewController+A_Parallax.h */, 99 | 695E92DD1B86D09300C7D40B /* UIViewController+A_Parallax.m */, 100 | 6939F41F1B8E899B00CBCC8C /* UIView+A_Parallax.h */, 101 | 6939F4201B8E899B00CBCC8C /* UIView+A_Parallax.m */, 102 | 6929C9631B9E3EC600141AB2 /* A_Parallax.h */, 103 | ); 104 | path = "A-Parallax"; 105 | sourceTree = ""; 106 | }; 107 | /* End PBXGroup section */ 108 | 109 | /* Begin PBXNativeTarget section */ 110 | 695E92AF1B86CA5C00C7D40B /* A-ParallaxDemo */ = { 111 | isa = PBXNativeTarget; 112 | buildConfigurationList = 695E92D31B86CA5C00C7D40B /* Build configuration list for PBXNativeTarget "A-ParallaxDemo" */; 113 | buildPhases = ( 114 | 695E92AC1B86CA5C00C7D40B /* Sources */, 115 | 695E92AD1B86CA5C00C7D40B /* Frameworks */, 116 | 695E92AE1B86CA5C00C7D40B /* Resources */, 117 | ); 118 | buildRules = ( 119 | ); 120 | dependencies = ( 121 | ); 122 | name = "A-ParallaxDemo"; 123 | productName = "A-ParallaxDemo"; 124 | productReference = 695E92B01B86CA5C00C7D40B /* A-ParallaxDemo.app */; 125 | productType = "com.apple.product-type.application"; 126 | }; 127 | /* End PBXNativeTarget section */ 128 | 129 | /* Begin PBXProject section */ 130 | 695E92A81B86CA5C00C7D40B /* Project object */ = { 131 | isa = PBXProject; 132 | attributes = { 133 | LastUpgradeCheck = 0640; 134 | ORGANIZATIONNAME = "Animax Deng"; 135 | TargetAttributes = { 136 | 695E92AF1B86CA5C00C7D40B = { 137 | CreatedOnToolsVersion = 6.4; 138 | DevelopmentTeam = M979YDKC23; 139 | }; 140 | }; 141 | }; 142 | buildConfigurationList = 695E92AB1B86CA5C00C7D40B /* Build configuration list for PBXProject "A-ParallaxDemo" */; 143 | compatibilityVersion = "Xcode 3.2"; 144 | developmentRegion = English; 145 | hasScannedForEncodings = 0; 146 | knownRegions = ( 147 | en, 148 | Base, 149 | ); 150 | mainGroup = 695E92A71B86CA5C00C7D40B; 151 | productRefGroup = 695E92B11B86CA5C00C7D40B /* Products */; 152 | projectDirPath = ""; 153 | projectRoot = ""; 154 | targets = ( 155 | 695E92AF1B86CA5C00C7D40B /* A-ParallaxDemo */, 156 | ); 157 | }; 158 | /* End PBXProject section */ 159 | 160 | /* Begin PBXResourcesBuildPhase section */ 161 | 695E92AE1B86CA5C00C7D40B /* Resources */ = { 162 | isa = PBXResourcesBuildPhase; 163 | buildActionMask = 2147483647; 164 | files = ( 165 | 695E92BF1B86CA5C00C7D40B /* Main.storyboard in Resources */, 166 | 695E92C41B86CA5C00C7D40B /* LaunchScreen.xib in Resources */, 167 | 695E92C11B86CA5C00C7D40B /* Images.xcassets in Resources */, 168 | ); 169 | runOnlyForDeploymentPostprocessing = 0; 170 | }; 171 | /* End PBXResourcesBuildPhase section */ 172 | 173 | /* Begin PBXSourcesBuildPhase section */ 174 | 695E92AC1B86CA5C00C7D40B /* Sources */ = { 175 | isa = PBXSourcesBuildPhase; 176 | buildActionMask = 2147483647; 177 | files = ( 178 | 695E92DF1B86D09300C7D40B /* UIViewController+A_Parallax.m in Sources */, 179 | 695E92BC1B86CA5C00C7D40B /* ViewController.m in Sources */, 180 | 695E92B91B86CA5C00C7D40B /* AppDelegate.m in Sources */, 181 | 6939F4211B8E899B00CBCC8C /* UIView+A_Parallax.m in Sources */, 182 | 695E92DE1B86D09300C7D40B /* A_ParallaxManager.m in Sources */, 183 | 695E92B61B86CA5C00C7D40B /* main.m in Sources */, 184 | ); 185 | runOnlyForDeploymentPostprocessing = 0; 186 | }; 187 | /* End PBXSourcesBuildPhase section */ 188 | 189 | /* Begin PBXVariantGroup section */ 190 | 695E92BD1B86CA5C00C7D40B /* Main.storyboard */ = { 191 | isa = PBXVariantGroup; 192 | children = ( 193 | 695E92BE1B86CA5C00C7D40B /* Base */, 194 | ); 195 | name = Main.storyboard; 196 | sourceTree = ""; 197 | }; 198 | 695E92C21B86CA5C00C7D40B /* LaunchScreen.xib */ = { 199 | isa = PBXVariantGroup; 200 | children = ( 201 | 695E92C31B86CA5C00C7D40B /* Base */, 202 | ); 203 | name = LaunchScreen.xib; 204 | sourceTree = ""; 205 | }; 206 | /* End PBXVariantGroup section */ 207 | 208 | /* Begin XCBuildConfiguration section */ 209 | 695E92D11B86CA5C00C7D40B /* Debug */ = { 210 | isa = XCBuildConfiguration; 211 | buildSettings = { 212 | ALWAYS_SEARCH_USER_PATHS = NO; 213 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 214 | CLANG_CXX_LIBRARY = "libc++"; 215 | CLANG_ENABLE_MODULES = YES; 216 | CLANG_ENABLE_OBJC_ARC = YES; 217 | CLANG_WARN_BOOL_CONVERSION = YES; 218 | CLANG_WARN_CONSTANT_CONVERSION = YES; 219 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 220 | CLANG_WARN_EMPTY_BODY = YES; 221 | CLANG_WARN_ENUM_CONVERSION = YES; 222 | CLANG_WARN_INT_CONVERSION = YES; 223 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 224 | CLANG_WARN_UNREACHABLE_CODE = YES; 225 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 226 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 227 | COPY_PHASE_STRIP = NO; 228 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 229 | ENABLE_STRICT_OBJC_MSGSEND = YES; 230 | GCC_C_LANGUAGE_STANDARD = gnu99; 231 | GCC_DYNAMIC_NO_PIC = NO; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_OPTIMIZATION_LEVEL = 0; 234 | GCC_PREPROCESSOR_DEFINITIONS = ( 235 | "DEBUG=1", 236 | "$(inherited)", 237 | ); 238 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 239 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 240 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 241 | GCC_WARN_UNDECLARED_SELECTOR = YES; 242 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 243 | GCC_WARN_UNUSED_FUNCTION = YES; 244 | GCC_WARN_UNUSED_VARIABLE = YES; 245 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 246 | MTL_ENABLE_DEBUG_INFO = YES; 247 | ONLY_ACTIVE_ARCH = YES; 248 | SDKROOT = iphoneos; 249 | TARGETED_DEVICE_FAMILY = "1,2"; 250 | }; 251 | name = Debug; 252 | }; 253 | 695E92D21B86CA5C00C7D40B /* Release */ = { 254 | isa = XCBuildConfiguration; 255 | buildSettings = { 256 | ALWAYS_SEARCH_USER_PATHS = NO; 257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 258 | CLANG_CXX_LIBRARY = "libc++"; 259 | CLANG_ENABLE_MODULES = YES; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | CLANG_WARN_BOOL_CONVERSION = YES; 262 | CLANG_WARN_CONSTANT_CONVERSION = YES; 263 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 264 | CLANG_WARN_EMPTY_BODY = YES; 265 | CLANG_WARN_ENUM_CONVERSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 268 | CLANG_WARN_UNREACHABLE_CODE = YES; 269 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 270 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 271 | COPY_PHASE_STRIP = NO; 272 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 273 | ENABLE_NS_ASSERTIONS = NO; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | GCC_C_LANGUAGE_STANDARD = gnu99; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 279 | GCC_WARN_UNDECLARED_SELECTOR = YES; 280 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 281 | GCC_WARN_UNUSED_FUNCTION = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 284 | MTL_ENABLE_DEBUG_INFO = NO; 285 | SDKROOT = iphoneos; 286 | TARGETED_DEVICE_FAMILY = "1,2"; 287 | VALIDATE_PRODUCT = YES; 288 | }; 289 | name = Release; 290 | }; 291 | 695E92D41B86CA5C00C7D40B /* Debug */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | CODE_SIGN_IDENTITY = "iPhone Developer"; 296 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 297 | INFOPLIST_FILE = "A-ParallaxDemo/Info.plist"; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | PROVISIONING_PROFILE = ""; 301 | }; 302 | name = Debug; 303 | }; 304 | 695E92D51B86CA5C00C7D40B /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 308 | CODE_SIGN_IDENTITY = "iPhone Developer"; 309 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 310 | INFOPLIST_FILE = "A-ParallaxDemo/Info.plist"; 311 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | PROVISIONING_PROFILE = ""; 314 | }; 315 | name = Release; 316 | }; 317 | /* End XCBuildConfiguration section */ 318 | 319 | /* Begin XCConfigurationList section */ 320 | 695E92AB1B86CA5C00C7D40B /* Build configuration list for PBXProject "A-ParallaxDemo" */ = { 321 | isa = XCConfigurationList; 322 | buildConfigurations = ( 323 | 695E92D11B86CA5C00C7D40B /* Debug */, 324 | 695E92D21B86CA5C00C7D40B /* Release */, 325 | ); 326 | defaultConfigurationIsVisible = 0; 327 | defaultConfigurationName = Release; 328 | }; 329 | 695E92D31B86CA5C00C7D40B /* Build configuration list for PBXNativeTarget "A-ParallaxDemo" */ = { 330 | isa = XCConfigurationList; 331 | buildConfigurations = ( 332 | 695E92D41B86CA5C00C7D40B /* Debug */, 333 | 695E92D51B86CA5C00C7D40B /* Release */, 334 | ); 335 | defaultConfigurationIsVisible = 0; 336 | defaultConfigurationName = Release; 337 | }; 338 | /* End XCConfigurationList section */ 339 | }; 340 | rootObject = 695E92A81B86CA5C00C7D40B /* Project object */; 341 | } 342 | -------------------------------------------------------------------------------- /A-ParallaxDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /A-ParallaxDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/20/15. 6 | // Copyright (c) 2015 Animax Deng. 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 | -------------------------------------------------------------------------------- /A-ParallaxDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/20/15. 6 | // Copyright (c) 2015 Animax Deng. 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 | -------------------------------------------------------------------------------- /A-ParallaxDemo/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 | -------------------------------------------------------------------------------- /A-ParallaxDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 88 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 109 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 145 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /A-ParallaxDemo/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /A-ParallaxDemo/Images.xcassets/backgroup.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "backgroup.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /A-ParallaxDemo/Images.xcassets/backgroup.imageset/backgroup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Animaxx/A-Parallax/66dcb1eccc2e17580c197fff7362e01b23318cf2/A-ParallaxDemo/Images.xcassets/backgroup.imageset/backgroup.jpg -------------------------------------------------------------------------------- /A-ParallaxDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | animax.$(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 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /A-ParallaxDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/20/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /A-ParallaxDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/20/15. 6 | // Copyright (c) 2015 Animax Deng. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "A_Parallax.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UIView *demoBox1; 15 | @property (weak, nonatomic) IBOutlet UIView *demoBox2; 16 | @property (weak, nonatomic) IBOutlet UILabel *noShadowLabel; 17 | 18 | @property (weak, nonatomic) IBOutlet UIView *operationArea; 19 | @property (weak, nonatomic) IBOutlet UIButton *changeShadowColorButton; 20 | @property (weak, nonatomic) IBOutlet UISlider *shadowRadiusSlider; 21 | @property (weak, nonatomic) IBOutlet UILabel *shadowRadiusLabel; 22 | 23 | @property (weak, nonatomic) IBOutlet UILabel *shadowFixedOffsetXLabel; 24 | @property (weak, nonatomic) IBOutlet UILabel *shadowFixedOffsetYLabel; 25 | @property (weak, nonatomic) IBOutlet UILabel *shadowDynamicLabel; 26 | 27 | @end 28 | 29 | @implementation ViewController { 30 | UIImageView *_backgroupView; 31 | } 32 | 33 | - (void)viewDidLoad { 34 | [super viewDidLoad]; 35 | } 36 | - (void)viewDidAppear:(BOOL)animated { 37 | [super viewDidAppear:animated]; 38 | 39 | [self A_ParallaxBackground:[UIImage imageNamed:@"backgroup"] withEffect:A_ParallaxBackgoundDisplayEffectWithOpacity | A_ParallaxBackgoundDisplayEffectWithTransform]; 40 | [_demoBox1 A_SetParallaxShadow:YES]; 41 | [_demoBox2 A_SetParallaxShadow:YES]; 42 | [_noShadowLabel A_SetParallaxShadow:YES]; 43 | 44 | _operationArea.layer.cornerRadius = 16.0f; 45 | _operationArea.layer.borderColor = [UIColor whiteColor].CGColor; 46 | _operationArea.layer.borderWidth = 1.0f; 47 | 48 | _changeShadowColorButton.layer.cornerRadius = 4.0f; 49 | _changeShadowColorButton.layer.borderColor = [UIColor whiteColor].CGColor; 50 | _changeShadowColorButton.layer.borderWidth = 2.0f; 51 | 52 | _demoBox2.layer.cornerRadius = _demoBox2.frame.size.width/2.0f; 53 | } 54 | 55 | - (BOOL)prefersStatusBarHidden { 56 | return YES; 57 | } 58 | 59 | - (IBAction)changedEnableShadow:(UISwitch *)sender { 60 | [_demoBox1 A_SetParallaxShadow:sender.on]; 61 | [_demoBox2 A_SetParallaxShadow:sender.on]; 62 | [_noShadowLabel A_SetParallaxShadow:sender.on]; 63 | } 64 | 65 | - (IBAction)updateShadowColor:(id)sender { 66 | CGFloat hue = ( arc4random() % 256 / 256.0 ); 67 | CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; 68 | CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; 69 | UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1.0f]; 70 | 71 | [[A_ParallaxManager shareInstance] setShadowColor:color]; 72 | } 73 | - (IBAction)updateShadowRadius:(id)sender { 74 | _shadowRadiusLabel.text = [NSString stringWithFormat:@"%.2f", _shadowRadiusSlider.value]; 75 | [[A_ParallaxManager shareInstance] setShadowRadius:_shadowRadiusSlider.value]; 76 | } 77 | 78 | - (IBAction)updateShadowFixedOffsetX:(UISlider *)sender { 79 | _shadowFixedOffsetXLabel.text = [NSString stringWithFormat:@"x:%.2f", sender.value]; 80 | CGPoint shadowFixedOffset = [A_ParallaxManager shareInstance].shadowFixedOffset; 81 | shadowFixedOffset.x = sender.value; 82 | [[A_ParallaxManager shareInstance] setShadowFixedOffset:shadowFixedOffset]; 83 | } 84 | - (IBAction)updateShadowFixedOffsetY:(UISlider *)sender { 85 | _shadowFixedOffsetYLabel.text = [NSString stringWithFormat:@"y:%.2f", sender.value]; 86 | CGPoint shadowFixedOffset = [A_ParallaxManager shareInstance].shadowFixedOffset; 87 | shadowFixedOffset.y = sender.value; 88 | [[A_ParallaxManager shareInstance] setShadowFixedOffset:shadowFixedOffset]; 89 | } 90 | - (IBAction)updateDynamicOffset:(UISlider *)sender { 91 | [[A_ParallaxManager shareInstance] setShadowDynamicOffset:sender.value]; 92 | _shadowDynamicLabel.text = [NSString stringWithFormat:@"%.1f", sender.value]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /A-ParallaxDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // A-ParallaxDemo 4 | // 5 | // Created by Animax Deng on 8/20/15. 6 | // Copyright (c) 2015 Animax Deng. 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Animax Deng 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 | # A-Parallax 2 | Controls and background parallax effect. 3 | 4 | # Recording from real device 5 | ![recording demo](https://raw.githubusercontent.com/Animaxx/A-Parallax/master/demoGif/demo.gif) 6 | 7 | # Usage 8 | First step, Add `#import "A_Parallax.h"` to your project 9 | 10 | ##### For setting parallax background: 11 | In your UIViewController `[self A_ParallaxBackgroup:<#UIImage instance for your controller background #>];` 12 | 13 | ##### For set control to be a parallax element: 14 | 15 | ```Objective-C 16 | [<#Your control instance#> A_SetParallax]; 17 | ``` 18 | 19 | 20 | Or you can set the depth and enable shadow for the parallax element: 21 | 22 | ```Objective-C 23 | [<#Your control instance#> A_SetParallaxDepth:1.0 andShadow:YES]; 24 | ``` 25 | 26 | 27 | Delete parallax effect: 28 | 29 | ```Objective-C 30 | [<#Your control instance#> A_DeleteParallax]; 31 | ``` 32 | 33 | -------------------------------------------------------------------------------- /demoGif/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Animaxx/A-Parallax/66dcb1eccc2e17580c197fff7362e01b23318cf2/demoGif/demo.gif --------------------------------------------------------------------------------