我正在尝试使用Facebook pop POPSpringAnimation动画UIButton的界限,但是我找不到我应该在swift中使用的替换NSValue.valueWithCGRect
这就是我想要做的:
@IBAction func buttonTapped(sender : UIButton) {
var springAnimation = POPSpringAnimation()
springAnimation.property = POPAnimatableProperty.propertyWithName(kPOPLayerBounds) as POPAnimatableProperty
springAnimation.springBounciness = 12.0
springAnimation.springSpeed = 10.0
springAnimation.toValue = NSValue.valueWithCGRect(newBounds)
shutterButton.pop_addAnimation(springAnimation, forKey: "size")
}
Run Code Online (Sandbox Code Playgroud) 我正在使用presentViewController和一个自定义modalPresentationStyle呈现一个UIViewController,以实现Facebook POP动画过渡.
模态视图本身是完全动态的,使用代码中的Autolayout约束进行定义.没有用于支持模态的xib/storyboard.
我无法将模态视图置于屏幕中心!Autolayout是不够的,因为没有超级视图来添加约束!
我的呈现代码如下所示(取自FB POP代码示例):
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
{
UIView *fromView = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey].view;
fromView.tintAdjustmentMode = UIViewTintAdjustmentModeDimmed;
fromView.userInteractionEnabled = NO;
UIView *dimmingView = [[UIView alloc] initWithFrame:fromView.bounds];
dimmingView.backgroundColor = [UIColor colorWithRed:(24/255.0) green:(42/255.0) blue:(15/255.0) alpha:1.0];
dimmingView.layer.opacity = 0.0;
UIView *toView = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey].view;
toView.frame = CGRectMake(0,
0,
CGRectGetWidth(transitionContext.containerView.bounds) - 104.f,
CGRectGetHeight(transitionContext.containerView.bounds) - 320.f);
toView.center = CGPointMake(transitionContext.containerView.center.x, -transitionContext.containerView.center.y);
[transitionContext.containerView addSubview:dimmingView];
[transitionContext.containerView addSubview:toView];
POPSpringAnimation *positionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
positionAnimation.toValue = @(transitionContext.containerView.center.y);
positionAnimation.springBounciness = 10;
[positionAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[transitionContext completeTransition:YES];
}]; …Run Code Online (Sandbox Code Playgroud) objective-c uiviewcontroller uiviewanimationtransition ios facebook-pop
目前有一种方法可以使用Facebook Pop框架进行自动布局,还是必须使用弹簧和支柱?我一直在阅读它是可能的,但我不知道语法是什么能够为视图的顶部约束设置动画.
我能够使用约束更改设置动画
[UIView animateWithDuration:0.5
delay:0.5
usingSpringWithDamping:0.7
initialSpringVelocity:0.7
options:0
animations:^{
[self.closeButton layoutIfNeeded];
} completion:NULL];
Run Code Online (Sandbox Code Playgroud)
但我的印象是,这也可以使用Facebook POP库完成.任何人都可以指出我正确的方向找出如何?
谢谢
我正在开发一个旧项目,想要摆脱POP 框架,我确信任何动画都可以使用本机 iOS 框架来完成。
这是旧代码:
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
springAnimation.toValue = [NSValue valueWithCGRect:rect];
springAnimation.velocity = [NSValue valueWithCGRect:CGRectMake(springVelocity, springVelocity, 0, 0)];
springAnimation.springBounciness = springBounciness;
springAnimation.springSpeed = springSpeed;
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
// cool code here
}
}];
[self.selectedViewController.view pop_addAnimation:springAnimation forKey:@"springAnimation"];
Run Code Online (Sandbox Code Playgroud)
我尝试过的:
[UIView animateWithDuration:1.0
delay:0
usingSpringWithDamping:springBounciness
initialSpringVelocity:springVelocity
options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.selectedViewController.view.frame = rect;
} completion:^(BOOL finished) {
// cool code here
}];
Run Code Online (Sandbox Code Playgroud)
但我没有得到相同的结果,并且出现了一些问题:
springBounciness在流行音乐中相当于usingSpringWithDamping?springSpeed动画中相当于什么UIView?POPSpringAnimation? …我想安装facebook的pop框架.我有一个多项目工作区,没有使用可可豆荚.我想要最简单,最笨,最快的安装.
从流行自述文件:
"...您可以将项目添加到工作区并采用提供的配置文件或手动将pop子目录下的文件复制到项目中.如果手动安装,请确保通过将-lc ++包含到项目中来链接C++标准库链接器标志."
#import <POP/POP.h>到我的.m文件中.结果:找不到"POP/POP.h".
我想我做错了什么,但绝对不知道从哪里开始寻找.
我正在使用Facebook Pop的弹簧动画在X轴上制作动画.它工作正常,除了我似乎无法改变速度.看来,velocity属性是我读过的唯一方法,但我为它设置的值似乎没有任何效果.我做错了什么,或者这是一个错误?
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
anim.velocity = @(100.);
anim.springBounciness = 15;
anim.toValue = @(self.scrollView.frame.size.width/2);
anim.beginTime = .05 * i + CACurrentMediaTime();
[thisView.layer pop_addAnimation:anim forKey:@"myKey"];
Run Code Online (Sandbox Code Playgroud) 如何使用Facebook POP框架进行循环动画.
我试图设置类中NO命名的属性removedOnCompletion,POPBasicAnimation但它不起作用.
我正在使用POP框架在Facebook纸质应用程序中实现HomeScreen动画(即当用户平移动态增长的帖子并稳定到全屏时水平滚动的帖子),我可能知道如何实现这一点以及视图是什么(即滚动视图或者collectionview)我必须用来实现那个动画.任何帮助赞赏.
Facebook刚开源他们的真棒POP动画框架,它是由Core Animation构建的,我无法弄清楚如何为图层背景颜色设置动画.
这是我的代码:
POPBasicAnimation *colorAnimation = [POPBasicAnimation animation];
colorAnimation.property = [POPAnimatableProperty propertyWithName:kPOPViewBackgroundColor];
if (_pressed)
{
colorAnimation.toValue = (id)[UIColor redColor].CGColor;
}
else
{
colorAnimation.toValue = (id)[UIColor greenColor].CGColor;
}
[_button pop_addAnimation:colorAnimation forKey:@"colorAnimation"];
Run Code Online (Sandbox Code Playgroud)
本.toValue应该只接受NSNumber或NSValue但我无法弄清楚如何在色彩传递给动画作为.toValue.
有人知道吗?