zrxq / uiview-easingfunctions Goto Github PK
View Code? Open in Web Editor NEWA category on UIView that allows to use custom easing functions with block-based animations.
License: Other
A category on UIView that allows to use custom easing functions with block-based animations.
License: Other
I am using autolayout and and constraints more and more. One use is to set the constant of leading space of a content view to push the view left or right while there is a width constraint and no trailing constraint. It is how I am creating a sidebar interface.
I see that this project can manipulate some values but I do not see how I would modify this code to work with modifying a constant on a constraint. How would you do this sort of animation to allow for easing?
I'm building against the iOS8 SDK through Xcode6.
If I run it on a iOS7 device, the animations work properly.
However on an iOS8 device the animations are 'spazzy'.
When I use EasingFunctions with CABasicAnimation I get the wrong behavior when adding an easing function.
Example code:
[self.button setEasingFunction:CubicEaseOut forKeyPath:@"transform.scale"];
CATransform3D trans = [(CALayer *)[self.button.layer presentationLayer] transform];
CABasicAnimation *animation = nil;
animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[animation setFromValue:[NSNumber numberWithDouble:1.0f]];
[animation setDuration:1.0f];
animation.fillMode = kCAFillModeForwards;
self.button.layer.transform = CATransform3DMakeScale(1.25, 1.25, 1.25);
[self.button.layer addAnimation:animation forKey:@"transform.scale"];
Explanation:
I'm animating a button to scale from 1 to 1.25 and instead of growing it firsts shrinks until you can't see it and then when the animation time passes it is becoming 1.25
When using a UIView animation with a delay > 0.0 the animation seems to be played back with a duration of 0.0 โ there's no visible animation at all:
[self.view setEasingFunction:BackEaseOut forKeyPath:@"frame"];
[UIView animateWithDuration:0.5 delay:0.3 options:0 animations:^{
self.view.frame = someRect;
} completion:NULL];
If I use, for example, an ExponentialEaseInOut on a UIView that is 100 points tall and aligned to the bottom of its parent view to animate its origin and size to make it appear to grow bottom-aligned to 200 points, the bottom "detaches" from the bottom of the superview. Expected behavior is that the same easing math applies to both the origin and size, so the bottom appears to remain fixed.
[view setEasingFunction:ExponentialEaseInOut forKeyPath:@"frame"];
[UIView animateWithDuration:0.5
delay:0
options:0
animations:^{
view.frame = CGRectMake(0,view.superview.frame.size.height - 200,view.frame.size.width,200); // animates to correct new position and size, but the bottom doesn't stay "fixed" to the bottom of the superview
}
completion:nil];
If you set an easing function for an animation which runs in a segue, the coordinates of the start and end frames for the view change (or perhaps it just ignores the ones you set). Commenting out the easing function returns to the expected beginning and end points.
Here's an example animation block (inside a segue between two view controllers):
[UIView animateWithDuration:2.0
delay:delay
options:UIViewAnimationOptionCurveEaseOut
animations:^{
[view setEasingFunction:QuinticEaseInOut forKeyPath:@"frame"];
view.frame = CGRectMake(view.frame.origin.x,
view.frame.origin.y-1024,
view.frame.size.width,
view.frame.size.height);
//start view.frame=CGRectMake(view.frame.origin.x, view.frame.origin.y....)
Commenting out the [view setEasingFunction... line has an expected start and end point, uncommenting it sets it to a negative value, and ignores my start and end points.
Not sure if this is my problem or something in AHEasing - keen to help solve it but not sure where to begin!
UPDATE: It seems that any animation I set up in iOS 8 ignores the start and end points of the animation, not just those in segues. Surely I'm not the only one experiencing this?
- (void)setEasingFunction:(ViewEasingFunctionPointerType)function forKeyPath:(NSString *)keyPath
warning: incompatible pointer types sending 'float (float)' to parameter of type 'ViewEasingFunctionPointerType' (aka 'CGFloat (*)(CGFloat)')
Hey there @zrxq I was wondering your opinion on making the podspec for this library depend on AHEasing, as at the minute in order to use this library you have to specify separately AHEasing in the podfile.
Using the easing functions on my iPhone 5s is fine, but when I move to the 5s simulator in XCode 6, the animations are super spazzy.
Not really an issue, but I would love to be able to add this project remotely with CocoaPods, rather than adding it locally via a podspec.
The first time my UIView+EasingFunctions animations run, it always seems to lag/stutter and show up midway through. Would it be possible to preload any animation data that UIView+EasingFunctions has to perform the first time the animation is performed? Or is this an optimization I need to perform in my own code?
In the Simulator, animation has a strange behavior.
In the device, no animation works.
Would be great if UIView-EasingFunctions could implement bezier curve control points (https://developer.apple.com/library/mac/documentation/cocoa/reference/CAMediaTimingFunction_class/Introduction/Introduction.html#//apple_ref/occ/clm/CAMediaTimingFunction/functionWithControlPoints::::) to utilize http://cubic-bezier.com/
- (void)setBezierControlPoints:::: forKeyPath:(NSString *)keyPath;
I am trying the code below , it works fine in iPhone 5 , iPhone 4 but doesn't work properly in iPhone 5S.
[viewButtonContainer setEasingFunction:QuadraticEaseIn forKeyPath:@"center"];
[UIView animateWithDuration:0.3 delay:waitFor options:UIViewAnimationOptionCurveLinear animations:^{
viewButtonContainer.center = CGPointMake(0,0);
} completion:^(BOOL finished) {
}];
Something to compile for ARM-64 may be ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.