Tag: uiviewanimation

如何以编程方式将search栏添加到UITableView标头?

我将如何去编程添加一个search栏到一个uitableview头? 具体来说,我有一个酒吧button的项目,当它被按下,我想animation在search栏中的表视图标题,当取消button被按下时,将animation返回到视图和标题缩放恢复正常。 这可能吗? 谢谢。

如何在自动布局中添加视差效果

我正在使用大小类的自动布局。 我想在UITableViewCell上添加视差效果,所以我参考。 以下链接 https://github.com/fernandospr/FSParallaxTableView https://github.com/jberlana/JBParallaxCell 但他们没有使用自动布局,任何想法如何应用视差效果的imageView大小类上和自动布局时使用。

无法在animation期间将mainview旁边的子视图最小化

我有两个视图,videoView(它是mainView)和subVideoView(它是mainView的子视图)。 我正在试图同时使用animation同时最小化两个视图,如下面的代码所示。 我能够最小化videoView(即mainView)而不是subVideoView。 但是,当我隐藏代码以最小化videoView(即mainView)时,我能够最小化subVideoView。 我相信它必须以我的animation方式做一些事情。 有人可以请教,我怎样才能最大限度地减less这两个意见(成比例)同时animation,结果与下面的结果。 已有的代码结果 func minimiseOrMaximiseViews(animationType: String){ UIView.animate(withDuration: 0.5, delay: 0, options: [], animations: { [unowned self] in switch animationType { case "minimiseView" : // Minimising subVideoView self.subVideoView.frame = CGRect(x: self.mainScreenWidth – self.minSubVideoViewWidth – self.padding, y: self.mainScreenHeight – self.minSubVideoViewHeight – self.padding, width: self.minSubVideoViewWidth, height: self.minSubVideoViewHeight) // Minimising self ie videoView self.frame = […]

为什么顺序UIViewanimation同时显示?

我已经写了一些代码,依次在屏幕上移动一些对象。 当每个对象完成移动,下一个开始。 代码的结构与此类似: 模型: moveObject { // Code to move the object … [delegate moved:self]; } 代表: moved:(MyClass *)o { UIView* v = [self viewForObject:o]; [UIView animateWithDuration:1.0 animations:^{ [v setCenter: [model center]]; } completion:^(BOOL finished){ // Move object [model moveObject]; }]; } 虽然代码似乎运行良好,但屏幕上发生的事情是,animation被分组为批次:大量的一次都发生,然后另一个组都开始。 如果我在[model moveObject];行放置一个断点[model moveObject]; 然后在没有任何animation被显示在屏幕上的情况下被finished设置为true几次。 然后,偶尔, finished将被设置为false ,并且在我让debugging继续之后,所有的animation将在屏幕上执行。 编辑 : 但是,如果我更改代码,以便在moveObject被调用时偶尔不移动对象,而是返回没有动作的对象,并且等待用户移动对象(并且因此通过委托的moved:select器调用回代码),那么animation的短串顺序发生。 ie问题似乎只发生在代码处于无限循环时。 怎么了?

UICollectionviewCellanimation

我想animation的collectionview单元格,animation应该是这样的: 第一个单元出现,然后延迟一段时间后, 第二个单元将出现一些animation ,这将继续像所有的单元格一样。 如何做到这一点?

在使用UILongPressGestureRecognizer拖动另一个视图的同时在关键窗口上animation视图

我已经将UILongPressGestureRecognizer添加到视图中,并且在长按事件之后,用户可以拖动视图。 我已经在关键窗口添加了一个视图(需要导航和标签栏控制器上的自定义视图,这就是为什么需要添加它在关键窗口)使用下面的代码: // add the custom view on the key window. UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow; [currentWindow addSubview:customView]; 现在,当我将第一个视图拖到(screenSize/2)点之外时,我希望customView从视图的右侧进行animation处理。 我试了下面的代码来呈现视图: // animate the customView view. [UIView animateWithDuration:0.50f animations:^{ customView.frame = CGRectMake(SCREEN_WIDTH – customViewWidth, 0, customViewWidth, SCREEN_HEIGHT); } completion:nil]; 但是这个观点并没有出现animation。 我什至尝试使用dispatch_async(dispatch_get_main_queue(),{}); 但仍然没有成功。 任何帮助将不胜感激。

如何使用UIPopoverPresentationControlleranimationpreferredContentSize?

我能够通过简单地设置preferredContentSize成功地改变我提供的popover框架。 我现在想animation内容大小的变化,但我没有成功。 它只是即时更新,实际上我设置的延迟甚至没有被尊重。 内容大小如何变化? //In viewDidAppear: UIView.animateWithDuration(5, delay: 3, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.25, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in self.preferredContentSize = CGSizeMake(320, 400) }, completion: nil)

没有使用完成块,可以在UIView上做多个animation

这只是为了说明问题,简单的问题,我的具体代码要复杂得多。 比方说,我有UILabel是左上angular的位置。 有了这个代码,我会把它移到右上angular: // labelMove is moved to TOP RIGHT [UIView animateWithDuration:1.0f delay:2.0f options:UIViewAnimationOptionCurveEaseOut animations:^ { labelMove.center = CGPointMake(250.0f, 40.0f); } completion:nil]; 如果我有这个代码: // labelMove is moved to TOP RIGHT [UIView animateWithDuration:1.0f delay:2.0f options:UIViewAnimationOptionCurveEaseOut animations:^ { labelMove.center = CGPointMake(250.0f, 40.0f); } completion:nil]; // labelMove is moved to BOTTOM RIGHT [UIView animateWithDuration:1.0f delay:2.0f options:UIViewAnimationOptionCurveEaseOut animations:^ { […]

如何在需要时停止UIViewanimation?

我有这个代码: -(void)animationLoop{ CGPoint oldPoint = CGPointMake(myCircleUIView.frame.origin.x, myCircleUIView.frame.origin.y); [UIView animateWithDuration:1.0 animations: ^{ myCircleUIView.frame = CGRectMake(myCircleUIView.frame.origin.x + [self randomFloatingGenerator], myCircleUIView.frame.origin.y + [self randomFloatingGenerator], myCircleUIView.frame.size.width, myCircleUIView.frame.size.height); } completion: ^(BOOL finished) { [UIView animateWithDuration:1.0 animations:^{ myCircleUIView.frame = CGRectMake(oldPoint.x, oldPoint.y, myCircleUIView.frame.size.width, myCircleUIView.frame.size.height);} completion: ^(BOOL finished) {[self animationLoop];}]; }]; } 但是我试图停止与它交互的animation,但[myCircleUIView.layer removeAllAnimations]; 会不会做这个工作,有什么build议吗?

顺利更新运行animation

我有一些图片,我运行连续的animation。 如何平滑地更新这些正在运行的animation,以便它们之间没有可见的转换,除非部分animation。 例如旋转和缩放图像,然后更新animation以旋转原样,但略微放大。 我目前有一个明显的变化。 我可以想象,缩放应该在一个animation块中完成,并且像以前一样运行旋转animation,问题就出现在旋转会在缩放时停止。 我需要它是无缝的。 例如,这个代码块不会导致平滑的缩放,即使它使用UIViewAnimationOptionBeginFromCurrentState [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseOut //| UIViewAnimationOptionRepeat animations:(void (^)(void)) ^{ imageViewToScale.transform = CGAffineTransformMakeScale(1.2, 1.2); } completion:^(BOOL finished){ //imageViewToScale.transform=CGAffineTransformIdentity; }];