Tag: uiviewanimation

UIViewanimationlayoutIf需要不起作用

我正在使用此消息来将客户视图设置为设备屏幕的下边缘。 我连接了布局约束,并将初始常量设置为-60。 当该值设置为0时,我期望视图顶部animation。 但不幸的是,预期的function不工作。 即使调用方法,当界面方向改变时,视图也是希望的。 我使用Xcode 6.4和iOS 8作为基础SDK。 任何帮助将不胜感激。 if (alertVisible) { self.alertViewVerticalConstraint.constant = 0; [UIView animateWithDuration:0.25 animations: ^{ [self.view bringSubviewToFront:self.alertView]; self.alertView.alpha = 0.5; [self.alertView layoutIfNeeded]; }]; } else { self.alertViewVerticalConstraint.constant = -60; [UIView animateWithDuration:0.25 animations: ^{ self.alertView.alpha = 0.0; [self.alertView layoutIfNeeded]; }]; }

UIViewanimation无法调整视图的大小

我正在使用下面的代码来animationselectionMoreOptionView的外观 [selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 0)]; [self.view insertSubview:selectionMoreOptionView aboveSubview:lightBoxView]; [lightBoxView setAlpha:0.0]; [UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{ [lightBoxView setAlpha:0.5]; [selectionMoreOptionView setFrame:CGRectMake(974, 56, 50, 100)]; } completion:^(BOOL finished) { }]; 但它不是animation而是只是在没有animation的情况下出现。 我做错了什么?

新视图控制器被推入堆栈后,UIViewanimation继续运行

解决了。 可笑的尴尬。 我没有使用实例variables,我在实现中将它声明为花括号。 真的很挣扎。 我有一个视图控制器pipe理一个animation倒数计时器。 animation是使用recursion的UIViewanimation和一个简单的int ivar减less。 像下面这样(这是一个简化的片段): – (void) animate { [UIView animateWithDuration:0.75f delay:0.25f options:UIViewAnimationCurveEaseInOut animations:^{ aView.center = newCenter; counter–; } completion:^(BOOL finished) { if (counter != 0) [self animate]; }]; } 在倒计时期间,用户可以轻扫以进入下一步,而不是等待计时器完成倒计时。 当用户刷新一个新的视图控制器 – 当前视图控制器的一个新实例 – 被压入堆栈,并使用下一步的值: TimerViewController * vc = (TimerViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"Timer"]; [vc setTask: _task + 1]; [self.navigationController pushViewController:vc animated:YES]; 新的视图控制器滑动到位并开始倒计时,但前一个视图控制器继续animation,在debugging器中,我可以清楚地看到这个视图控制器的另一个实例,我将popup一个回到,仍然运行animation,导致一个视图移动不正常。 两个不同的视图控制器实例是animation相同的aView实例? […]

animation时无法同时满足约束条件

我有六个用户约束设置与IB看起来像这样: H:|-(593)-[UIView(411)]-(20)-| V:|-(20)-[UIView(288)]-(396)-| 我通过更改约束然后调用layoutIfNeeded来增长和缩小视图。 例如,为了发展我的观点,我会做: H:|-(20)-[UIView(984)]-(20)-| V:|-(20)-[UIView(663)]-(20)-| 然后打电话 [UIView animateWithDuration:.5 animations:^{ [self.view layoutIfNeeded]; }]; 这种技术会增长和缩小我的观点,它看起来不错,但我给了一个相当混乱的警告: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the […]

如何停止UIViewAnimationOptionRepeat UIViewanimation?

我在UIView子类中有以下代码: [element setAlpha: 0.0f]; [UIView animateWithDuration: 0.4 delay: 0.0 options: UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations: ^{ [element setAlpha: 1.0f]; } completion: ^(BOOL finished){ if (finished) { return; } }]; 然后,当我想停止animation时,我发送以下消息到视图本身: [[self layer] removeAllAnimations]; 但它什么都不做…我怎样才能停止animation?

用drawRect UIViewanimationbackgroundColor:

我有一个观点,能够自我反思。 这实际上是UICollectionView一个子类,但我只是在与UIView特定的东西挣扎; backgroundColor。 我只是添加了一个UIPanGestureRecognizer ,保存起始点在UIGestureRecognizerStateBegan和终点在UIGestureRecognizerStateChanged 。 然后我使用-drawRect:方法来绘制实际的path: – (void)awakeFromNib { UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)]; [self addGestureRecognizer:pan]; } – (void)panGesture:(UIPanGestureRecognizer *)panRecon { if([panRecon state] == UIGestureRecognizerBegan) { startPoint = [panRecon locationInView:self]; } else if([panRecon state] == UIGestureRecognizerChanged) { endPoint = [panRecon locationInView:self]; [self setNeedsDisplay]; } else if([panRecon state] == UIGestureRecognizerEnded /* || failed […]

animationUIView,如果它更接近或离开

我看到这个线程,但解决scheme不是我要找的。 我想popup一个类似于SpringBoard中的应用程序(看起来更接近)的animation,并使其消失,将其移出。 我试图给框架设置animation效果,但效果是内容没有resize:不幸的是我不能给视图的内容分配约束; 结果应该是如果视图以正确的尺寸显示并且仅调整“graphics上下文”的大小。 帮帮我!

如何避免在iOS上延迟块调用的保留周期

我真的很难过这个。 我一直在阅读所有关于如何正确处理块内variables的信息。 注意:我不使用弧。 所以说,我有一个这样的animation: [UIView animateWithDuration:.5 animations:^{ textCard.alpha = 1.f; self.dotView.alpha = 1.f; self.subtitles.alpha = 0; }completion:^(BOOL finished){ [self.playerLayer removeFromSuperlayer]; self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.vidPlayer]; self.playerLayer.frame = self.vidView.bounds; [self.vidView.layer insertSublayer:self.playerLayer atIndex:0]; [self.subtitles removeFromSuperview]; self.subtitles = [sub autorelease]; [UIView animateWithDuration:.3 delay:1 options:UIViewAnimationOptionAllowUserInteraction animations:^{ textCard.alpha = 0.f; sub.alpha = 1.f; }completion:^(BOOL finished){ self.queuedVid = NO; if (self.shouldPlay == […]

iOS – 如何减慢UISlideranimation?

我正在尝试在更改值时减慢UISlider的animation。 到目前为止,我已经尝试了旧的UIViewanimation方法: [UIView beginAnimations:@"slider" context:nil]; [UIView setAnimationDuration:5.0]; [self.slider setValue:2 animated:YES]; [UIView commitAnimations]; 而新的基于块的方法: [UIView animateWithDuration:5.0 animations:^{ [self.slider setValue:2 animated:YES]; }]; 我尝试过和没有animated:YES值设置。 在所有情况下,滑块都以默认速度animation。 是否有另一种策略,我应该看看自定义animation的速度? 我应该inheritance滑块并覆盖任何东西吗?

无限旋转UIView,直到调用停止方法,并将视图animation回到起始点

我需要无限期地旋转一个UIView 。 但是,我需要能够停止每一个方法,因为我试图实现像一个自定义的UIActivityIndicatorView 。 视图还需要animation回到其开始旋转(0度)。 到目前为止,我一直试图实现的所有方法的问题是,我无法手动停止它(直到持续时间结束),animation不平滑或我的视图不会返回到其开始位置。 基本上,我需要的是一个animation旋转我的看法永远。 一旦我调用一个方法来停止它,它应该返回到它的起点并停止。 我已经尝试了一些修改的答案,但没有成功。