Welcome to the animation specialists!
I came across Origami Facebook, which uses its Pop library for iOS.
Origami examples
All the tutorials (on their website + everywhere on the Internet) seem to be focused on mastering his quartz composer. I am wondering how to get the exported code (click the Origami icon in QC and select Export iOS Code.) To my iOS app.

So, I started by downloading the “2D Waggle” example : A 2D Waggle example
Here's what the exported code looks like:
#import "ViewController.h"
#import <POP/POP.h>
#import <POP/POPLayerExtras.h>
@interface ViewController ()
@property (nonatomic) CGFloat popAnimationProgress;
@property (nonatomic) CGFloat popAnimationProgress;
@end
@implementation ViewController
- (void)togglePopAnimation:(BOOL)on {
POPSpringAnimation *animation = [self pop_animationForKey:@"popAnimation"];
if (!animation) {
animation = [POPSpringAnimation animation];
animation.springBounciness = 5;
animation.springSpeed = 10;
animation.property = [POPAnimatableProperty propertyWithName:@"popAnimationProgress" initializer:^(POPMutableAnimatableProperty *prop) {
prop.readBlock = ^(ViewController *obj, CGFloat values[]) {
values[0] = obj.popAnimationProgress;
};
prop.writeBlock = ^(ViewController *obj, const CGFloat values[]) {
obj.popAnimationProgress = values[0];
};
prop.threshold = 0.001;
}];
[self pop_addAnimation:animation forKey:@"popAnimation"];
}
animation.toValue = on ? @(1.0) : @(0.0);
}
- (void)setPopAnimationProgress:(CGFloat)progress {
_popAnimationProgress = progress;
POPLayerSetTranslationX(self.layer.layer, POPPixelsToPoints(progress));
}
- (void)togglePopAnimation:(BOOL)on {
POPSpringAnimation *animation = [self pop_animationForKey:@"popAnimation"];
if (!animation) {
animation = [POPSpringAnimation animation];
animation.springBounciness = 5;
animation.springSpeed = 10;
animation.property = [POPAnimatableProperty propertyWithName:@"popAnimationProgress" initializer:^(POPMutableAnimatableProperty *prop) {
prop.readBlock = ^(ViewController *obj, CGFloat values[]) {
values[0] = obj.popAnimationProgress;
};
prop.writeBlock = ^(ViewController *obj, const CGFloat values[]) {
obj.popAnimationProgress = values[0];
};
prop.threshold = 0.001;
}];
[self pop_addAnimation:animation forKey:@"popAnimation"];
}
animation.toValue = on ? @(1.0) : @(0.0);
}
- (void)setPopAnimationProgress:(CGFloat)progress {
_popAnimationProgress = progress;
POPLayerSetTranslationY(self.layer.layer, POPPixelsToPoints(-progress));
}
static inline CGFloat POPPixelsToPoints(CGFloat pixels) {
static CGFloat scale = -1;
if (scale < 0) {
scale = [UIScreen mainScreen].scale;
}
return pixels / scale;
}
And here is the code that I tried to use to interact with the generated material:
-(void)awakeFromNib
{
UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
[self addGestureRecognizer:pan];
}
static float firstX=0,firstY=0;
-(void)move:(id)sender {
[self bringSubviewToFront:[(UIPanGestureRecognizer*)sender view]];
CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:self];
if ([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {
firstX = [[sender view] center].x;
firstY = [[sender view] center].y;
[self togglePopAnimationX:YES];
[self togglePopAnimationY:YES];
}
else if ([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) {
[self togglePopAnimationX:NO];
[self togglePopAnimationY:NO];
}
translatedPoint = CGPointMake(firstX+translatedPoint.x, firstY+translatedPoint.y);
if ([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateChanged) {
POPLayerSetTranslationX(self.layer, translatedPoint.x);
POPLayerSetTranslationY(self.layer, translatedPoint.y);
}
}
Suffice it to say that this does NOT work :(
So, I guess my question is how to start the animation?
, , "Swipe" QC Origami (. )

- , , , .
!