Skip to content

Commit 418bb68

Browse files
committed
Merge pull request IFTTT#1497
2 parents d3f87ee + fdf1163 commit 418bb68

11 files changed

+936
-843
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
osx_image: xcode611
22
language: objective-c
33
before_install: gem install cocoapods xcpretty obcd slather -N
4-
cache: cocoapods
54
podfile: Example/Podfile
65
env:
76
- LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8

Example/JazzHandsDemo.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@
396396
COPY_PHASE_STRIP = NO;
397397
GCC_C_LANGUAGE_STANDARD = gnu99;
398398
GCC_DYNAMIC_NO_PIC = NO;
399+
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
400+
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES;
399401
GCC_OPTIMIZATION_LEVEL = 0;
400402
GCC_PREPROCESSOR_DEFINITIONS = (
401403
"DEBUG=1",

Example/Pods/Headers/Public/JazzHands/IFTTTCornerRadiusAnimation.h

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/project.pbxproj

+826-814
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JazzHands/IFTTTAnimationFrame.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
@property (nonatomic, assign) CGRect frame;
1515
@property (nonatomic, assign) CGFloat alpha;
16+
@property (nonatomic, assign) CGFloat cornerRadius;
1617
@property (nonatomic, assign) BOOL hidden;
1718
@property (nonatomic, copy) UIColor *color;
1819
@property (nonatomic, assign) CGFloat angle;

JazzHands/IFTTTAnimationKeyFrame.h

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// values into keyframe objects.
2121
//
2222
+ (NSArray *)keyFramesWithTimesAndAlphas:(NSInteger)pairCount,...;
23+
+ (NSArray *)keyFramesWithTimesAndCornerRadius:(NSInteger)pairCount,...;
2324
+ (NSArray *)keyFramesWithTimesAndFrames:(NSInteger)pairCount,...;
2425
+ (NSArray *)keyFramesWithTimesAndHiddens:(NSInteger)pairCount,...;
2526
+ (NSArray *)keyFramesWithTimesAndColors:(NSInteger)pairCount,...;
@@ -29,6 +30,7 @@
2930
+ (NSArray *)keyFramesWithTimesAndConstraint:(NSInteger)pairCount,...;
3031

3132
+ (instancetype)keyFrameWithTime:(NSInteger)time andAlpha:(CGFloat)alpha;
33+
+ (instancetype)keyFrameWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius;
3234
+ (instancetype)keyFrameWithTime:(NSInteger)time andFrame:(CGRect)frame;
3335
+ (instancetype)keyFrameWithTime:(NSInteger)time andHidden:(BOOL)hidden;
3436
+ (instancetype)keyFrameWithTime:(NSInteger)time andColor:(UIColor*)color;
@@ -38,6 +40,7 @@
3840
+ (instancetype)keyFrameWithTime:(NSInteger)time andConstraint:(CGFloat)constraint;
3941

4042
- (id)initWithTime:(NSInteger)time andAlpha:(CGFloat)alpha;
43+
- (id)initWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius;
4144
- (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame;
4245
- (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden;
4346
- (id)initWithTime:(NSInteger)time andColor:(UIColor*)color;

JazzHands/IFTTTAnimationKeyFrame.m

+53-28
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ + (NSArray *)keyFramesWithTimesAndAlphas:(NSInteger)pairCount,...
3737
}
3838
}
3939

40+
+ (NSArray *)keyFramesWithTimesAndCornerRadius:(NSInteger)pairCount,...
41+
{
42+
va_list argumentList;
43+
NSInteger time;
44+
CGFloat cornerRadius;
45+
if (pairCount > 0) {
46+
NSMutableArray *keyFrames = [NSMutableArray arrayWithCapacity:(NSUInteger)pairCount];
47+
48+
va_start(argumentList, pairCount);
49+
50+
for (int i=0; i<pairCount; i++) {
51+
time = va_arg(argumentList, NSInteger);
52+
cornerRadius = (CGFloat)va_arg(argumentList, double); // use double to suppress a va_arg conversion warning
53+
IFTTTAnimationKeyFrame *keyFrame = [IFTTTAnimationKeyFrame keyFrameWithTime:time
54+
andCornerRadius:cornerRadius];
55+
[keyFrames addObject:keyFrame];
56+
}
57+
58+
va_end(argumentList);
59+
60+
return [NSArray arrayWithArray:keyFrames];
61+
}
62+
else {
63+
return nil;
64+
}
65+
}
66+
4067
+ (NSArray *)keyFramesWithTimesAndFrames:(NSInteger)pairCount,...
4168
{
4269
va_list argumentList;
@@ -226,6 +253,13 @@ + (instancetype)keyFrameWithTime:(NSInteger)time andAlpha:(CGFloat)alpha
226253
return keyFrame;
227254
}
228255

256+
+ (instancetype)keyFrameWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius
257+
{
258+
IFTTTAnimationKeyFrame *keyFrame = [[self alloc] initWithTime:time
259+
andCornerRadius:cornerRadius];
260+
return keyFrame;
261+
}
262+
229263
+ (instancetype)keyFrameWithTime:(NSInteger)time andFrame:(CGRect)frame
230264
{
231265
IFTTTAnimationKeyFrame *keyFrame = [[self alloc] initWithTime:time
@@ -279,10 +313,8 @@ + (instancetype)keyFrameWithTime:(NSInteger)time andConstraint:(CGFloat)constrai
279313
}
280314

281315
- (id)initWithTime:(NSInteger)time
282-
{
283-
self = [super init];
284-
285-
if (self) {
316+
{
317+
if ((self = [self init])) {
286318
self.time = time;
287319
self.easingFunction = IFTTTEasingFunctionLinear;
288320
}
@@ -292,20 +324,25 @@ - (id)initWithTime:(NSInteger)time
292324

293325
- (id)initWithTime:(NSInteger)time andAlpha:(CGFloat)alpha
294326
{
295-
self = [self initWithTime:time];
296-
297-
if (self) {
327+
if ((self = [self initWithTime:time])) {
298328
self.alpha = alpha;
299329
}
300330

301331
return self;
302332
}
303333

334+
- (id)initWithTime:(NSInteger)time andCornerRadius:(CGFloat)cornerRadius
335+
{
336+
if ((self = [self initWithTime:time])) {
337+
self.cornerRadius = cornerRadius;
338+
}
339+
340+
return self;
341+
}
342+
304343
- (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame
305344
{
306-
self = [self initWithTime:time];
307-
308-
if (self) {
345+
if ((self = [self initWithTime:time])) {
309346
self.frame = frame;
310347
}
311348

@@ -314,9 +351,7 @@ - (id)initWithTime:(NSInteger)time andFrame:(CGRect)frame
314351

315352
- (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden
316353
{
317-
self = [self initWithTime:time];
318-
319-
if (self) {
354+
if ((self = [self initWithTime:time])) {
320355
self.hidden = hidden;
321356
}
322357

@@ -325,9 +360,7 @@ - (id)initWithTime:(NSInteger)time andHidden:(BOOL)hidden
325360

326361
- (id)initWithTime:(NSInteger)time andColor:(UIColor*)color
327362
{
328-
self = [self initWithTime:time];
329-
330-
if (self) {
363+
if ((self = [self initWithTime:time])) {
331364
self.color = color;
332365
}
333366

@@ -336,9 +369,7 @@ - (id)initWithTime:(NSInteger)time andColor:(UIColor*)color
336369

337370
- (id)initWithTime:(NSInteger)time andAngle:(CGFloat)angle
338371
{
339-
self = [self initWithTime:time];
340-
341-
if (self) {
372+
if ((self = [self initWithTime:time])) {
342373
self.angle = angle;
343374
}
344375

@@ -347,29 +378,23 @@ - (id)initWithTime:(NSInteger)time andAngle:(CGFloat)angle
347378

348379
- (id)initWithTime:(NSInteger)time andTransform3D:(IFTTTTransform3D *)transform
349380
{
350-
self = [self initWithTime:time];
351-
352-
if (self) {
381+
if ((self = [self initWithTime:time])) {
353382
self.transform = transform;
354383
}
355384

356385
return self;
357386
}
358387

359388
- (id)initWithTime:(NSInteger)time andScale:(CGFloat)scale {
360-
self = [self initWithTime:time];
361-
362-
if (self) {
389+
if ((self = [self initWithTime:time])) {
363390
self.scale = scale;
364391
}
365392

366393
return self;
367394
}
368395

369396
- (id)initWithTime:(NSInteger)time andConstraint:(CGFloat)constraint {
370-
self = [self initWithTime:time];
371-
372-
if (self) {
397+
if ((self = [self initWithTime:time])) {
373398
self.constraintConstant = constraint;
374399
}
375400

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// IFTTTCornerRadiusAnimation.h
3+
// JazzHands
4+
//
5+
// Created by Nuno Gonçalves on 3/8/15.
6+
// Copyright (c) 2015 IFTTT Inc. All rights reserved.
7+
//
8+
9+
#import "IFTTTAnimation.h"
10+
11+
@interface IFTTTCornerRadiusAnimation : IFTTTAnimation
12+
13+
@end
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// IFTTTCornerRadiusAnimation.m
3+
// JazzHands
4+
//
5+
// Created by Nuno Gonçalves on 3/8/13.
6+
// Copyright (c) 2015 IFTTT Inc. All rights reserved.
7+
//
8+
9+
#import "IFTTTJazzHands.h"
10+
11+
@implementation IFTTTCornerRadiusAnimation
12+
13+
- (void)animate:(NSInteger)time
14+
{
15+
if (self.keyFrames.count <= 1) return;
16+
17+
IFTTTAnimationFrame *animationFrame = [self animationFrameForTime:time];
18+
self.view.layer.cornerRadius = animationFrame.cornerRadius;
19+
}
20+
21+
- (IFTTTAnimationFrame *)frameForTime:(NSInteger)time
22+
startKeyFrame:(IFTTTAnimationKeyFrame *)startKeyFrame
23+
endKeyFrame:(IFTTTAnimationKeyFrame *)endKeyFrame
24+
{
25+
IFTTTAnimationFrame *animationFrame = [IFTTTAnimationFrame new];
26+
animationFrame.cornerRadius = [self tweenValueForStartTime:startKeyFrame.time
27+
endTime:endKeyFrame.time
28+
startValue:startKeyFrame.cornerRadius
29+
endValue:endKeyFrame.cornerRadius
30+
atTime:time];
31+
32+
return animationFrame;
33+
}
34+
35+
@end

JazzHands/IFTTTJazzHands.h

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#import "IFTTTAnimatedScrollViewController.h"
1919

2020
#import "IFTTTAlphaAnimation.h"
21+
#import "IFTTTCornerRadiusAnimation.h"
2122
#import "IFTTTFrameAnimation.h"
2223
#import "IFTTTHideAnimation.h"
2324
#import "IFTTTColorAnimation.h"

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Jazz Hands supports several types of animations:
7474

7575
+ **IFTTTFrameAnimation** moves and sizes views.
7676
+ **IFTTTAlphaAnimation** creates fade effects.
77+
+ **IFTTTCornerRadiusAnimation** animates the `layer.cornerRadius` of a view.
7778
+ **IFTTTHideAnimation** hides and shows views.
7879
+ **IFTTTAngleAnimation** for rotation effects.
7980
+ **IFTTTTransform3DAnimation** for 3D transforms.

0 commit comments

Comments
 (0)