- Fix present picker controller

This commit is contained in:
giuseppenuc committed 2019-03-10 16:29:02 +01:00
1 parent 2aa49f6ad1
commit 5974642e25
277 files changed
+14514 -11692

No files matched your search

@@ -0,0 +1,19 @@
//
// DGActivityIndicatorAnimation.h
// DGActivityIndicatorExample
//
// Created by Danil Gontovnik on 8/10/16.
// Copyright © 2016 Danil Gontovnik. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "DGActivityIndicatorAnimationProtocol.h"
@interface DGActivityIndicatorAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
- (CABasicAnimation *)createBasicAnimationWithKeyPath:(NSString *)keyPath;
- (CAKeyframeAnimation *)createKeyframeAnimationWithKeyPath:(NSString *)keyPath;
- (CAAnimationGroup *)createAnimationGroup;
@end
@@ -0,0 +1,35 @@
//
// DGActivityIndicatorAnimation.m
// DGActivityIndicatorExample
//
// Created by Danil Gontovnik on 8/10/16.
// Copyright © 2016 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimation.h"
@implementation DGActivityIndicatorAnimation
- (CABasicAnimation *)createBasicAnimationWithKeyPath:(NSString *)keyPath {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath];
animation.removedOnCompletion = NO;
return animation;
}
- (CAKeyframeAnimation *)createKeyframeAnimationWithKeyPath:(NSString *)keyPath {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:keyPath];
animation.removedOnCompletion = NO;
return animation;
}
- (CAAnimationGroup *)createAnimationGroup {
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = NO;
return animationGroup;
}
- (void)setupAnimationInLayer:(CALayer *)layer withSize:(CGSize)size tintColor:(UIColor *)tintColor {
}
@end
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallBeatAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallBeatAnimation: DGActivityIndicatorAnimation
@end
@@ -19,21 +19,21 @@
CGFloat y = (layer.bounds.size.height - circleSize) / 2;
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = duration;
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
scaleAnimation.values = @[@1.0f, @0.75f, @1.0f];
// Opacity animation
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = duration;
opacityAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
opacityAnimation.values = @[@1.0f, @0.2f, @1.0f];
// Aniamtion
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.duration = duration;
animation.animations = @[scaleAnimation, opacityAnimation];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallClipRotateAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallClipRotateAnimation: DGActivityIndicatorAnimation
@end
@@ -14,7 +14,7 @@
CGFloat duration = 0.75f;
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.6f, 0.6f, 1.0f)],
@@ -22,13 +22,13 @@
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
// Rotate animation
CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
CAKeyframeAnimation *rotateAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.z"];
rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
rotateAnimation.keyTimes = scaleAnimation.keyTimes;
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, rotateAnimation];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallClipRotateMultipleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallClipRotateMultipleAnimation: DGActivityIndicatorAnimation
@end
@@ -56,7 +56,7 @@
- (CAAnimation *)createAnimationInDuration:(CGFloat) duration withTimingFunction:(CAMediaTimingFunction *) timingFunction reverse:(BOOL) reverse {
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
@@ -66,7 +66,7 @@
scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
// Rotate animation
CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
CAKeyframeAnimation *rotateAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.z"];
if (!reverse) {
rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
@@ -78,7 +78,7 @@
rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, rotateAnimation];
animation.repeatCount = HUGE_VALF;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallClipRotatePulseAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallClipRotatePulseAnimation: DGActivityIndicatorAnimation
@end
@@ -16,7 +16,7 @@
// Small circle
{
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0.0f, @0.3f, @1.0f];
scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
@@ -39,7 +39,7 @@
// Big circle
{
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
@@ -49,7 +49,7 @@
scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
// Rotate animation
CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
CAKeyframeAnimation *rotateAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.z"];
rotateAnimation.values = @[@0, @M_PI, @(2 * M_PI)];
rotateAnimation.keyTimes = scaleAnimation.keyTimes;
@@ -57,7 +57,7 @@
rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, rotateAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallGridBeatAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallGridBeatAnimation: DGActivityIndicatorAnimation
@end
@@ -20,7 +20,7 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
animation.beginTime = CACurrentMediaTime();
animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallGridPulseAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallGridPulseAnimation: DGActivityIndicatorAnimation
@end
@@ -20,21 +20,21 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
scaleAnimation.values = @[@1.0f, @0.5f, @1.0f];
scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
opacityAnimation.values = @[@1.0f, @0.7f, @1.0f];
opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, opacityAnimation];
animation.beginTime = CACurrentMediaTime();
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallPulseAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallPulseAnimation: DGActivityIndicatorAnimation
@end
@@ -19,7 +19,7 @@
NSArray *timeBegins = @[@0.12f, @0.24f, @0.36f];
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.2f :0.68f :0.18f :1.08f];
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform"];
animation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3f, 0.3f, 1.0f)],
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallPulseSyncAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallPulseSyncAnimation: DGActivityIndicatorAnimation
@end
@@ -21,7 +21,7 @@
CAMediaTimingFunction *timingFunciton = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform.translation.y"];
animation.duration = duration;
animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallRotateAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallRotateAnimation: DGActivityIndicatorAnimation
@end
@@ -16,7 +16,7 @@
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.7f :-0.13f :0.22f :0.86f];
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
scaleAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 1.0f)],
@@ -26,7 +26,7 @@
scaleAnimation.timingFunctions = @[timingFunction, timingFunction];
// Rotate animation
CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
CAKeyframeAnimation *rotateAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.z"];
rotateAnimation.keyTimes = @[@0.0f, @0.5f, @1.0f];
rotateAnimation.values = @[@0, @-M_PI, @(-2 * M_PI)];
@@ -34,7 +34,7 @@
rotateAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, rotateAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallScaleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallScaleAnimation: DGActivityIndicatorAnimation
@end
@@ -14,21 +14,21 @@
CGFloat duration = 1.0f;
// Scale animation
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
CABasicAnimation *scaleAnimation = [self createBasicAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = duration;
scaleAnimation.fromValue = @0.0f;
scaleAnimation.toValue = @1.0f;
// Opacity animation
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
CABasicAnimation *opacityAnimation = [self createBasicAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = duration;
opacityAnimation.fromValue = @1.0f;
opacityAnimation.toValue = @0.0f;
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, opacityAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallScaleMultipleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallScaleMultipleAnimation: DGActivityIndicatorAnimation
@end
@@ -15,21 +15,21 @@
NSArray *beginTimes = @[@0.0f, @0.2f, @0.4f];
// Scale animation
CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
CABasicAnimation *scaleAnimation = [self createBasicAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = duration;
scaleAnimation.fromValue = @0.0f;
scaleAnimation.toValue = @1.0f;
// Opacity animation
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = duration;
opacityAnimation.keyTimes = @[@0.0f, @0.05f, @1.0f];
opacityAnimation.values = @[@0.0f, @1.0f, @0.0f];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, opacityAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallScaleRippleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallScaleRippleAnimation: DGActivityIndicatorAnimation
@end
@@ -15,7 +15,7 @@
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.21f :0.53f :0.56f :0.8f];
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = duration;
scaleAnimation.keyTimes = @[@0.0f, @0.7f];
@@ -23,7 +23,7 @@
scaleAnimation.timingFunction = timingFunction;
// Opacity animation
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = duration;
opacityAnimation.keyTimes = @[@0.0f, @0.7f, @1.0f];
@@ -31,7 +31,7 @@
opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, opacityAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallScaleRippleMultipleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallScaleRippleMultipleAnimation: DGActivityIndicatorAnimation
@end
@@ -16,7 +16,7 @@
NSArray *timeOffsets = @[@0.0f, @0.2f, @0.4f];
// Scale animation
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.duration = duration;
scaleAnimation.keyTimes = @[@0.0f, @0.7f];
@@ -24,7 +24,7 @@
scaleAnimation.timingFunction = timingFunction;
// Opacity animation
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = duration;
opacityAnimation.keyTimes = @[@0.0f, @0.7f, @1.0f];
@@ -32,7 +32,7 @@
opacityAnimation.timingFunctions = @[timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[scaleAnimation, opacityAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 mRocker. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallSpinFadeLoader : NSObject<DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallSpinFadeLoader : DGActivityIndicatorAnimation
@end
@@ -26,14 +26,14 @@
NSArray *beginTimes = @[@0, @0.12, @0.24, @0.36, @0.48, @0.6, @0.72, @0.84];
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *scaleAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
scaleAnimation.keyTimes = @[@0, @0.5, @1];
scaleAnimation.values = @[@1, @0.4, @1];
scaleAnimation.duration = duration;
CAKeyframeAnimation *opacityAnimaton = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimaton = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimaton.keyTimes = @[@0, @0.5, @1];
@@ -43,12 +43,11 @@
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
CAAnimationGroup *animationGroup = [self createAnimationGroup];;
animationGroup.animations = @[scaleAnimation, opacityAnimaton];
animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animationGroup.duration = duration;
animationGroup.repeatCount = HUGE;
animationGroup.removedOnCompletion = NO;
for (int i = 0; i < 8; i++) {
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallTrianglePathAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallTrianglePathAnimation: DGActivityIndicatorAnimation
@end
@@ -20,7 +20,7 @@
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform"];
animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallZigZagAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallZigZagAnimation: DGActivityIndicatorAnimation
@end
@@ -17,7 +17,7 @@
CGFloat deltaY = size.height / 2 - circleSize / 2;
// Circle 1 animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform"];
animation.duration = duration;
animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorBallZigZagDeflectAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorBallZigZagDeflectAnimation: DGActivityIndicatorAnimation
@end
@@ -17,7 +17,7 @@
CGFloat deltaY = size.height / 2 - circleSize / 2;
// Circle 1 animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform"];
animation.duration = duration;
animation.keyTimes = @[@0.0f, @0.33f, @0.66f, @1.0f];
@@ -6,9 +6,9 @@
// Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorCookieTerminatorAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorCookieTerminatorAnimation: DGActivityIndicatorAnimation
@end
@@ -42,8 +42,7 @@
jawLayer.opacity = 1.0f;
jawLayer.transform = CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_4, 0.0f, 0.0f, 1.0f);
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CABasicAnimation *transformAnimation = [self createBasicAnimationWithKeyPath:@"transform"];
transformAnimation.beginTime = beginTime;
transformAnimation.duration = 0.3f;
transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation((1.0f - 2.0f * i) * M_PI_4, 0.0f, 0.0f, 1.0f)];
@@ -66,13 +65,12 @@
cookieLayer.opacity = 1.0f;
cookieLayer.cornerRadius = cookieSize / 2.0f;
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
CABasicAnimation *transformAnimation = [self createBasicAnimationWithKeyPath:@"transform"];
transformAnimation.duration = 1.8f;
transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f);
transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f)];
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-3.0f * (cookieSize + cookiePadding), 0.0f, 0.0f)];
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.removedOnCompletion = NO;
transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
[layer addSublayer:cookieLayer];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorDoubleBounceAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorDoubleBounceAnimation: DGActivityIndicatorAnimation
@end
@@ -27,8 +27,7 @@
circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
circle.backgroundColor = tintColor.CGColor;
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 2.0f;
transformAnimation.beginTime = beginTime - (1.0f * i);
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorFiveDotsAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorFiveDotsAnimation: DGActivityIndicatorAnimation
@end
@@ -43,13 +43,12 @@
CATransform3D t5 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
t5 = CATransform3DScale(t5, 1.f, 1.0f, 0.0f);
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.values = @[[NSValue valueWithCATransform3D:t1],
[NSValue valueWithCATransform3D:t2],
[NSValue valueWithCATransform3D:t3],
[NSValue valueWithCATransform3D:t4],
[NSValue valueWithCATransform3D:t5]];
transformAnimation.removedOnCompletion = NO;
transformAnimation.beginTime = beginTime;
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 1.0f;
@@ -79,13 +78,12 @@
CATransform3D t4 = CATransform3DMakeTranslation(0.0f, 0.0f, 0.0f);
t4 = CATransform3DScale(t4, 0.3f, 0.3f, 0.0f);
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.values = @[[NSValue valueWithCATransform3D:t1],
[NSValue valueWithCATransform3D:t2],
[NSValue valueWithCATransform3D:t3],
[NSValue valueWithCATransform3D:t4]];
transformAnimation.keyTimes = @[@(0.0f), @(0.25f), @(0.75f), @(1.0f)];
transformAnimation.removedOnCompletion = NO;
transformAnimation.beginTime = beginTime;
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 1.0f;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorLineScaleAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorLineScaleAnimation: DGActivityIndicatorAnimation
@end
@@ -19,7 +19,7 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform.scale.y"];
animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
animation.values = @[@1.0f, @0.4f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorLineScalePartyAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorLineScalePartyAnimation: DGActivityIndicatorAnimation
@end
@@ -19,7 +19,7 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform.scale"];
animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
animation.values = @[@1.0f, @0.5f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorLineScalePulseOutAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorLineScalePulseOutAnimation: DGActivityIndicatorAnimation
@end
@@ -19,7 +19,7 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform.scale.y"];
animation.keyTimes = @[@0.0f, @0.5f, @1.0f];
animation.values = @[@1.0f, @0.4f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorLineScalePulseOutRapidAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorLineScalePulseOutRapidAnimation: DGActivityIndicatorAnimation
@end
@@ -19,7 +19,7 @@
CGFloat y = (layer.bounds.size.height - size.height) / 2;
// Animation
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale.y"];
CAKeyframeAnimation *animation = [self createKeyframeAnimationWithKeyPath:@"transform.scale.y"];
animation.keyTimes = @[@0.0f, @0.8f, @0.9f];
animation.values = @[@1.0f, @0.3f, @1.0f];
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorNineDotsAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorNineDotsAnimation: DGActivityIndicatorAnimation
@end
@@ -37,16 +37,15 @@
circle.opacity = 1.0f;
circle.cornerRadius = circle.bounds.size.height / 2.0f;
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)]];
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.values = @[@(0.5f), @(1.0f), @(0.5f)];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = NO;
CAAnimationGroup *animationGroup = [self createAnimationGroup];;
animationGroup.beginTime = beginTime;
animationGroup.repeatCount = HUGE_VALF;
animationGroup.duration = [durations[i] doubleValue];
@@ -6,9 +6,9 @@
// Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorRotatingSandglassAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorRotatingSandglassAnimation: DGActivityIndicatorAnimation
@end
@@ -31,8 +31,7 @@
circle.shouldRasterize = YES;
circle.rasterizationScale = [[UIScreen mainScreen] scale];
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 0.8f;
transformAnimation.beginTime = beginTime;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorRotatingSquaresAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorRotatingSquaresAnimation: DGActivityIndicatorAnimation
@end
@@ -30,8 +30,7 @@ static CGFloat degreesToRadians(CGFloat degrees) { return (degrees) / 180.0 * M_
square.shouldRasterize = YES;
square.rasterizationScale = [[UIScreen mainScreen] scale];
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.duration = 1.6f;
transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 2.0f);
transformAnimation.repeatCount = HUGE_VALF;
@@ -6,9 +6,9 @@
// Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorRotatingTrigonAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorRotatingTrigonAnimation: DGActivityIndicatorAnimation
@end
@@ -38,8 +38,7 @@
circle.shouldRasterize = YES;
circle.rasterizationScale = [[UIScreen mainScreen] scale];
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 2.0f;
transformAnimation.beginTime = beginTime - (i * transformAnimation.duration / 3.0f);;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorThreeDotsAnimation : NSObject<DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorThreeDotsAnimation : DGActivityIndicatorAnimation
@end
@@ -32,18 +32,17 @@
circle.opacity = 1.0f;
circle.cornerRadius = circle.bounds.size.width / 2.0f;
CAKeyframeAnimation *tranformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
CAKeyframeAnimation *tranformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
tranformAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5f, 0.5f, 0.0f)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)]];
CAKeyframeAnimation *opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
CAKeyframeAnimation *opacityAnimation = [self createKeyframeAnimationWithKeyPath:@"opacity"];
opacityAnimation.values = @[@(0.25f), @(1.0f)];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
CAAnimationGroup *animationGroup = [self createAnimationGroup];;
animationGroup.removedOnCompletion = NO;
animationGroup.autoreverses = YES;
animationGroup.beginTime = beginTime;
animationGroup.repeatCount = HUGE_VALF;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorTriangleSkewSpinAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorTriangleSkewSpinAnimation: DGActivityIndicatorAnimation
@end
@@ -17,7 +17,7 @@
CAMediaTimingFunction *timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.09f :0.57f :0.49f :0.9f];
// Rotation x animation
CAKeyframeAnimation *rotationXAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.x"];
CAKeyframeAnimation *rotationXAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.x"];
rotationXAnimation.duration = duration;
rotationXAnimation.keyTimes = @[@0.0f, @0.25f, @0.5f, @0.75f, @1.0f];
@@ -25,7 +25,7 @@
rotationXAnimation.timingFunctions = @[timingFunction, timingFunction, timingFunction, timingFunction];
// Rotation x animation
CAKeyframeAnimation *rotationYAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.y"];
CAKeyframeAnimation *rotationYAnimation = [self createKeyframeAnimationWithKeyPath:@"transform.rotation.y"];
rotationYAnimation.duration = duration;
rotationYAnimation.keyTimes = @[@0.0f, @0.25f, @0.5f, @0.75f, @1.0f];
@@ -33,7 +33,7 @@
rotationYAnimation.timingFunctions = @[timingFunction, timingFunction, timingFunction, timingFunction];
// Animation
CAAnimationGroup *animation = [CAAnimationGroup animation];
CAAnimationGroup *animation = [self createAnimationGroup];;
animation.animations = @[rotationXAnimation, rotationYAnimation];
animation.duration = duration;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorTriplePulseAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorTriplePulseAnimation: DGActivityIndicatorAnimation
@end
@@ -27,16 +27,15 @@
circle.cornerRadius = circle.bounds.size.height / 2.0f;
circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
CABasicAnimation *transformAnimation = [self createBasicAnimationWithKeyPath:@"transform"];
transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.0f, 0.0f, 0.0f)];
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)];
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
CABasicAnimation *opacityAnimation = [self createBasicAnimationWithKeyPath:@"opacity"];
opacityAnimation.fromValue = @(0.8f);
opacityAnimation.toValue = @(0.0f);
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = NO;
CAAnimationGroup *animationGroup = [self createAnimationGroup];;
animationGroup.beginTime = beginTime + i * 0.2f;
animationGroup.repeatCount = HUGE_VALF;
animationGroup.duration = 1.2f;
@@ -5,8 +5,8 @@
// Created by tripleCC on 15/6/28.
// Copyright (c) 2015年 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorTripleRingsAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorTripleRingsAnimation: DGActivityIndicatorAnimation
@end
@@ -29,20 +29,19 @@
circle.opacity = 1.0f;
circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
CABasicAnimation *transformAnimation = [self createBasicAnimationWithKeyPath:@"transform"];
transformAnimation.duration = 2.0f - i * 0.4f;
transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1f, 0.1f, 0.0f)];
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0f, 1.0f, 0.0f)];
transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
CABasicAnimation *opacityAnimation = [self createBasicAnimationWithKeyPath:@"opacity"];
opacityAnimation.duration = transformAnimation.duration;
opacityAnimation.fromValue = @(1.0f);
opacityAnimation.toValue = @(0.8f);
opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseOut];
CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.removedOnCompletion = NO;
CAAnimationGroup *animationGroup = [self createAnimationGroup];;
animationGroup.beginTime = beginTime + i * 0.4f;
animationGroup.repeatCount = HUGE_VALF;
animationGroup.duration = 2.0f;
@@ -6,8 +6,8 @@
// Copyright (c) 2015 Danil Gontovnik. All rights reserved.
//
#import "DGActivityIndicatorAnimationProtocol.h"
#import "DGActivityIndicatorAnimation.h"
@interface DGActivityIndicatorTwoDotsAnimation : NSObject <DGActivityIndicatorAnimationProtocol>
@interface DGActivityIndicatorTwoDotsAnimation: DGActivityIndicatorAnimation
@end
@@ -25,8 +25,7 @@
circle.transform = CATransform3DMakeScale(0.0f, 0.0f, 0.0f);
circle.backgroundColor = tintColor.CGColor;
CAKeyframeAnimation *transformAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = NO;
CAKeyframeAnimation *transformAnimation = [self createKeyframeAnimationWithKeyPath:@"transform"];
transformAnimation.repeatCount = HUGE_VALF;
transformAnimation.duration = 1.8f;
transformAnimation.beginTime = beginTime - (transformAnimation.duration / 2.0f * i);
@@ -44,11 +44,27 @@
static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
@interface DGActivityIndicatorView () {
CALayer *_animationLayer;
}
@end
@implementation DGActivityIndicatorView
#pragma mark -
#pragma mark Constructors
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
_tintColor = [UIColor whiteColor];
_size = kDGActivityIndicatorDefaultSize;
[self commonInit];
}
return self;
}
- (id)initWithType:(DGActivityIndicatorAnimationType)type {
return [self initWithType:type tintColor:[UIColor whiteColor] size:kDGActivityIndicatorDefaultSize];
}
@@ -63,6 +79,7 @@ static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
_type = type;
_size = size;
_tintColor = tintColor;
[self commonInit];
}
return self;
}
@@ -70,28 +87,41 @@ static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
#pragma mark -
#pragma mark Methods
- (void)commonInit {
self.userInteractionEnabled = NO;
self.hidden = YES;
_animationLayer = [[CALayer alloc] init];
[self.layer addSublayer:_animationLayer];
[self setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[self setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
}
- (void)setupAnimation {
self.layer.sublayers = nil;
_animationLayer.sublayers = nil;
id<DGActivityIndicatorAnimationProtocol> animation = [DGActivityIndicatorView activityIndicatorAnimationForAnimationType:_type];
if ([animation respondsToSelector:@selector(setupAnimationInLayer:withSize:tintColor:)]) {
[animation setupAnimationInLayer:self.layer withSize:CGSizeMake(_size, _size) tintColor:_tintColor];
self.layer.speed = 0.0f;
[animation setupAnimationInLayer:_animationLayer withSize:CGSizeMake(_size, _size) tintColor:_tintColor];
_animationLayer.speed = 0.0f;
}
}
- (void)startAnimating {
if (!self.layer.sublayers) {
if (!_animationLayer.sublayers) {
[self setupAnimation];
}
self.layer.speed = 1.0f;
self.hidden = NO;
_animationLayer.speed = 1.0f;
_animating = YES;
}
- (void)stopAnimating {
self.layer.speed = 0.0f;
_animationLayer.speed = 0.0f;
_animating = NO;
self.hidden = YES;
}
#pragma mark -
@@ -110,6 +140,7 @@ static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
_size = size;
[self setupAnimation];
[self invalidateIntrinsicContentSize];
}
}
@@ -117,8 +148,15 @@ static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
if (![_tintColor isEqual:tintColor]) {
_tintColor = tintColor;
for (CALayer *sublayer in self.layer.sublayers) {
sublayer.backgroundColor = tintColor.CGColor;
CGColorRef tintColorRef = tintColor.CGColor;
for (CALayer *sublayer in _animationLayer.sublayers) {
sublayer.backgroundColor = tintColorRef;
if ([sublayer isKindOfClass:[CAShapeLayer class]]) {
CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
shapeLayer.strokeColor = tintColorRef;
shapeLayer.fillColor = tintColorRef;
}
}
}
}
@@ -198,4 +236,27 @@ static const CGFloat kDGActivityIndicatorDefaultSize = 40.0f;
return nil;
}
#pragma mark -
#pragma mark Layout
- (void)layoutSubviews {
[super layoutSubviews];
_animationLayer.frame = self.bounds;
BOOL animating = _animating;
if (animating)
[self stopAnimating];
[self setupAnimation];
if (animating)
[self startAnimating];
}
- (CGSize)intrinsicContentSize {
return CGSizeMake(_size, _size);
}
@end
+2 -2
View File
@@ -15,9 +15,9 @@ Open and run the DGActivityIndicatorExample project in Xcode to see DGActivityIn
## Installation
### Cocoapods
### CocoaPods
Install Cocoapods if it is not installed yet:
Install CocoaPods if it is not installed yet:
``` bash
$ [sudo] gem install cocoapods