Fab*_*gue 2 animation nstimer ios swift
在我的测验的下一个问题要加载之前,我试着让按钮"摇晃".
动画看起来像
var timer = NSTimer()
UIView.animateWithDuration(0.1, animations: {
self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x + 2, self.IMGVIEWcat.center.y)
})
UIView.animateWithDuration(0.2, animations: {
self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x - 4, self.IMGVIEWcat.center.y)
})
UIView.animateWithDuration(0.3, animations: {
self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x + 2, self.IMGVIEWcat.center.y)
})
Run Code Online (Sandbox Code Playgroud)
在此之后调用以下函数
func QueryInformations(){
println("QueryInformationsStart")
self.ActivityIndicator.hidden = false
ObjectIDsArrayCount = ObjectIDsArray.count
var RandomQuestion = Int(arc4random_uniform(ObjectIDsArray.count + 0))
var QuestionID:String = ObjectIDsArray[RandomQuestion]
var query : PFQuery = PFQuery(className: "AddonQuiz")
query.getObjectInBackgroundWithId(QuestionID){
(ObjectHolder : PFObject!, error : NSError!) -> Void in
...
Run Code Online (Sandbox Code Playgroud)
现在动画开始但是下一个问题加载即时,是否有一些容易等待初学者实现"等待"直到动画完成?
我试着设定
var complet == true
Run Code Online (Sandbox Code Playgroud)
在动画中
并在查询功能
if complet = true {....
Run Code Online (Sandbox Code Playgroud)
但是这对我来说不起作用,我也发现了一些关于完成处理程序的信息,但是在我的代码中没有得到它.
如果要completion
在动画结束时使用块,则应使用带有delay
和options
参数的构造.
UIView.animateWithDuration(0.3, delay: 0.0, options: UIViewAnimationOptions.CurveLinear, animations: {
// put here the code you would like to animate
self.IMGVIEWcat.center = CGPointMake(self.IMGVIEWcat.center.x + 2, self.IMGVIEWcat.center.y)
}, completion: {(finished:Bool) in
// the code you put here will be compiled once the animation finishes
QueryInformations()
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14194 次 |
最近记录: |