草庐IT

AnimateWithDuration

全部标签

ios - 在完成之前取消 UIView animateWithDuration

我的项目中有这段代码:-(void)fadeImageView{[UIViewanimateWithDuration:1.0fdelay:0options:UIViewAnimationCurveEaseInOutanimations:^{self.imageView.alpha=0.0f;}completion:^(BOOLfinished){//maketheimageviewun-tappable.//ifthefadewascanceled,setthealphato1.0}];}但是,在某些情况下,我想在imageview变得不可见之前取消此操作。有没有办法在动画中取消这个动

iOS - UIView animateWithDuration 中的完成 block 被过早调用

我正在尝试在选择表格View单元格时制作一些动画。出于某种原因,完成block被调用得太早了。即使将持续时间设置为10秒,完成block也会立即被调用。[UIViewanimateWithDuration:10.0animations:^{message.frame=newFrame;}completion:^(BOOLfinished){NSLog(@"DONE???");}];有没有想过为什么会这样?谢谢。 最佳答案 来自UIViewdocumentation:completionAblockobjecttobeexecuted

swift - 引用 [weak self] 作为自己? animateWithDuration 内部导致崩溃

如果我在闭包上声明[weakself]并在UIView.animateWithDuration中将self引用为self?>应用会崩溃:someFunc(){[weakself](success)->VoidinUIView.animateWithDuration(0.25){self?.someView.alpha=1;}}使用消息发送到释放的实例但如果我有选择地提前解包self它不会someFunc(){[weakself](success)->Voidinifletweakself=self{UIView.animateWithDuration(0.25){weakself.so

ios - 如何暂停和恢复 UIView.animateWithDuration

我有一张图片,我在viewDidAppear中用这段代码制作了动画:UIView.animateWithDuration(10.5,delay:0.0,options:[],animations:{self.myImage.transform=CGAffineTransformMakeTranslation(0.0,200)},completion:nil)我想在点击myPauseButton时暂停动画,如果再次点击则恢复动画。 最佳答案 2个暂停和恢复动画的函数,我取自here并转换为Swift。funcpauseLayer(la

ios - 立即调用 Swift UIView animateWithDuration 完成闭包

我希望在指定的持续时间后调用此UIView动画的完成关闭,但它似乎立即触发...UIView.animateWithDuration(Double(0.2),animations:{self.frame=CGRectMake(0,-self.bounds.height,self.bounds.width,self.bounds.height)},completion:{finishedinif(finished){self.removeFromSuperview()}})有没有人遇到过这种情况?我读到其他人使用中心而不是框架来移动View更成功,但是我也遇到了同样的问题。

ios - Swift 2.0 中的 UIView.animateWithDuration?

在解释我的问题之前,重要的是要说我已经实现了thisquestion中提出的建议我认为我对这个animateWithDuration方法的怀疑是完全不同的,尽管这两个问题的标题非常相似。所以,我是一个Swift新手,我正在Swift中做一些小项目,基于我之前做过的ObjectiveC演示。这是我的objective-c代码:-(void)moveSideBarToXposition:(int)iXposition{[UIViewanimateWithDuration:0.5fdelay:0.1options:UIViewAnimationOptionTransitionNoneanim

ios - UIView.animateWithDuration 不是动画 Swift(再次)

注意:我已经检查了以下堆栈溢出问题:27907570,32229252,26118141,31604300我想要做的就是当连接到按钮的IBAction调用时在View中淡入淡出动画(通过alpha)。然后在点击View上的按钮时反转。我的问题可能在于我正在使用StoryboardView中ViewDock上的辅助View。该View在viewDidLoad时添加到subview,其中框架/边界设置为与superView相同(用于完整停留)之所以将其作为叠加View完成,是因为它是一个教程指示器。结果(与列出此问题的许多其他人一样)是View(和包含的控件)立即出现并立即消失。不褪色。我

ios - 是否有必要在 UIView.animateWithDuration(...) 的闭包中使用 [unowned self]?

UIView.animateWithDuration(1,animations:{[unownedself]inself.box.center=self.boxTopRightPosition},completion:{[unownedself]completedinself.box.hidden=true})是否需要避免内存泄漏? 最佳答案 不,在这种情况下不需要。animations和completion不被self保留,因此不存在强保留周期的风险。 关于ios-是否有必要在UIVi

iphone - bool 参数在 animateWithDuration :animations:completion: 中究竟做了什么

我提到了DOC它说:completion...ThisblockhasnoreturnvalueandtakesasingleBooleanargumentthatindicateswhetherornottheanimationsactuallyfinishedbeforethecompletionhandlerwascalled....但是我发现不管你是否使用bool参数,completion:block总是会在animations:block之后执行。就像下面显示的两个简单的基于block的动画代码片段一样,它们都在做同样的事情。[UIViewanimateWithDuratio

iphone - animateWithDuration :animations: block main thread?

我已将以下两种方法连接到我的UI中的单独按钮,但注意到在按下“版本1”按钮后,我无法再次按下该按钮,直到方法中的动画持续时间结束。我的理解是动画使用自己的线程,以免阻塞主应用程序。//VERSION1-(IBAction)fadeUsingBlock{NSLog(@"V1:Clicked...");[myLabelsetAlpha:1.0];[UIViewanimateWithDuration:1.5animations:^{[myLabelsetAlpha:0.0];}];}旧样式版本(如下)确实允许在动画计时器结束之前按下按钮,只需重置计时器以重新开始。这两者是否应该相同,我是否遗