Tag: uiviewanimation

animationDidStop用于组animation

我有一个组animation,但我无法检测何时点击animationDidStop。 我的代码示例: [group setDelegate:self]; [view.layer addAnimation:group forKey:@"groupAnimation"]; 你们谁知道我怎么知道什么时候组animation完成?

UIViewAnimationOptionBeginFromCurrentState具有基本animation的意外行为

我正在尝试执行这个基本的UIViewanimation时收到一个button点击: – (IBAction)buttonPress:(id)sender { self.sampleView.alpha = 0.0; [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState animations:^{self.sampleView.alpha = 1.0;} completion:NULL]; } 在点击button之前,视图是可见的,并且具有1.0的alpha值。 当我发送button动作,我期望视图在2秒内从alpha = 0.0到alpha = 1.0淡入,但是这不会发生。 当我删除UIViewAnimationOptionBeginFromCurrentStateanimation工作正常。 这似乎与UIViewAnimationOptionBeginFromCurrentState选项设置,alpha = 0.0没有被设置,animation被忽略,因为它认为它已经在1.0。 我想了解为什么会发生这种情况,因为苹果文档指出,如果另一个animation不在进行中, UIViewAnimationOptionBeginFromCurrentState没有效果: “ UIViewAnimationOptionBeginFromCurrentState从与当前飞行animation相关联的当前设置开始animation,如果该键不存在,则在新animation开始之前允许任何飞行animation完成,如果另一个animation未在飞行中,钥匙没有效果“。

在Swift UIViewanimation不工作,错误的参数错误

我试图做一个animation,并使用下面的代码。 我得到“不能调用'animateWithDuration'types的参数列表'(浮动列转换,延迟:FloatLiteralConvertible,选项:UIViewAnimationOptions,animation:() – >() – > $ T4,完成:(布尔) – >(布尔) – > $ T5)'“错误 。 这意味着我使用错误的参数。 我可能是错的。 请帮忙。 我无法真正解决它。 var basketTopFrame = CGRect() basketTopFrame = dropPlace.frame var mytimer : NSTimer = NSTimer .scheduledTimerWithTimeInterval(2.0, target: self, selector: "restart", userInfo: nil, repeats: false) UIView.animateWithDuration(1.0, delay: 0.1, options: UIViewAnimationOptions.CurveEaseIn , animations: { var pickPlace = basketTopFrame }, completion: […]

改变NavigationItem提示时奇怪的animation

我有这些ViewControllers添加在故事板: 没有一个与自定义类相关,一切都来自纯故事板。 iOS7上iPhone模拟器上的video 这只在iOS7上使用AutoLayout时发生。 其他人看到这个? 下载问题的示例项目

iOS – 多个animation块?

我有多个animation,必须作为链运行。 我一直在处理这个问题的方法是使用completionHandler并运行下一个animation块。 有一个更清洁的方式来处理这个问题吗? [UIView animateWithDuration:1 animations^{ // perform first animation }completion:(BOOL finished){ [UIView animateWithDuration:1 animations^{ // perform second animation }completion:(BOOL finished){ }]; }];

顺时针旋转UIView大于180度的angular度

我正在将时钟臂指向12点到当前时间。 如果是11点,我想让arm顺时针旋转到11点的位置。 但是当然如果我使用: CGAffineTransform rotation = CGAffineTransformMakeRotation(2*M_PI*11/12); [UIView animateWithDuration:3.0 animations:^{ clockArm.transform = rotation; }]; 旋转逆时针旋转。 我试过了: CGFloat angle = 2*M_PI*11/12; CGAffineTransform firstRotation = CGAffineTransformMakeRotation(M_PI-0.001); CGFloat firstRotationTime = 3.0*(M_PI/angle); CGAffineTransform secondRotation = CGAffineTransformMakeRotation(angle); CGFloat secondRotationTime = 3.0 – firstRotationTime; [UIView animateWithDuration:firstRotationTime delay:0.0 options:UIViewAnimationCurveLinear animations:^{ self.clockArm1.transform = firstRotation; } completion:^(BOOL finished) { [UIView animateWithDuration:secondRotationTime delay:0.0 options:UIViewAnimationCurveLinear animations:^{ […]

UIVisualEffectView如何在iOS中拖动时修改模糊度?

目前,我正在使用UIVisualEffectView将模糊应用于图像。 我有一个UIScrollView。 当我拉下scrollView,在我的“scrollViewDidScroll”方法中,我正在改变UIVisualEffectView的alpha。 当前的行为是,当我在视图中拖动时,模糊半径平滑地变化。 问题当然是,我不应该这样做。 获取有关更改UIVisualEffectView的Alpha值的警告。 我已经看到人们说使用animation模糊的平滑过渡,如下所示: 如何淡入淡出UIVisualEffectView和/或UIBlurEffect进出? 但是,我还没有看到任何让我在做这个事情的时候,比如说一个泛式手势或者其他东西。 我的意思是,如果我用定时的数量来制作animation,一切都很好。 但是在拖动过程中这样做?

UIViewController半屏“抽屉滑动”animation

我想有一个UIViewController出现在右边的“幻灯片”animation。 不像一个推塞格,不喜欢Facebook的应用程序。 我想要新的ViewController滑动当前的TOP(不推)它,但只覆盖屏幕的一部分,而其他部分显示第一个ViewController。 我所尝试过的:我所得到的最接近的是通过创build一个自定义的segue与以下内容: – (void)perform { __block UIViewController *src = (UIViewController *) self.sourceViewController; __block UIViewController *dst = (UIViewController *) self.destinationViewController; CATransition* transition = [CATransition animation]; transition.duration = .50; transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromRight; [src.navigationController.view.layer addAnimation:transition forKey:@"SwitchToView1"]; [src.navigationController pushViewController:dst animated:NO]; } 这实现了我所要做的animation,但它覆盖了整个第一个ViewController。 我如何让它在某个时候停下来,而不是覆盖整个事物呢? 我正在使用故事板,这是我第一次尝试任何一种新的animation。

如何animationremoveFromSuperview

我用下面的animation显示了我的子视图: CATransition *transition = [CATransition animation]; transition.duration = 0.3; transition.type = kCATransitionReveal; [webView.layer addAnimation:transition forKey:nil]; [self.view addSubview:webView]; 但是现在我想删除我的子视图。 我如何添加animation来做到这一点? 像其他的CATransition一样? 什么时候添加这个? 在addSubview之前或之后?

Swift 3 UIViewanimation

由于升级我的项目swift 3我的自动布局约束animation不工作; 更具体的说,他们正在攫取新的职位,而不是animation。 UIView.animate(withDuration: 0.1, delay: 0.1, options: UIViewAnimationOptions.curveEaseIn, animations: { () -> Void in constraint.constant = ButtonAnimationValues.YPosition.DefaultOut() self.layoutIfNeeded() }, completion: { (finished) -> Void in // …. }) 我知道他们添加了UIViewPropertyAnimator类,但还没有尝试。