小比例动画按预期工作,但返回正常大小的比例动画有些奇怪;它以正确的正常比例制作动画,然后再次制作相同的动画,但速度要快得多。
这是我的代码:
func changeState(sender:UIButton){
println(insideSolidLayer.animationKeys())
if (shouldAnimate){
shouldAnimate = false
if (on){
animateSolidAway()
}else{
animateSolidIn()
}
on = !on
}
}
func animateSolidAway(){
insideSolidLayer.transform = CATransform3DMakeScale(1, 1, 1)
let scaleAnimate:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimate.fromValue = 1
scaleAnimate.toValue = 0
scaleAnimate.duration = 0.2;
scaleAnimate.delegate = self
scaleAnimate.removedOnCompletion = false
scaleAnimate.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
insideSolidLayer.addAnimation(scaleAnimate, forKey: "scaleSmallAnimation")
}
func animateSolidIn(){
insideSolidLayer.transform = CATransform3DMakeScale(0, 0, 0)
let scaleAnimate:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimate.fromValue = 0
scaleAnimate.toValue = 1
scaleAnimate.duration = 3;
scaleAnimate.delegate = self
scaleAnimate.removedOnCompletion = false
scaleAnimate.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
insideSolidLayer.addAnimation(scaleAnimate, forKey: "scaleNormalAnimation")
}
override func animationDidStop(anim: CAAnimation!, finished flag: Bool) {
if(anim.isKindOfClass(CABasicAnimation)){
if (insideSolidLayer != nil && insideSolidLayer.animationKeys() != nil && insideSolidLayer.animationKeys().count > 0){
if contains(insideSolidLayer.animationKeys() as [String], "scaleSmallAnimation"){
if (anim == insideSolidLayer.animationForKey("scaleSmallAnimation")){
println("-animationDidStop- -scaleSmallAnimation-")
insideSolidLayer.transform = CATransform3DMakeScale(0, 0, 0)
shouldAnimate = true
}
}
if contains(insideSolidLayer.animationKeys() as [String], "scaleNormalAnimation"){
if (anim == insideSolidLayer.animationForKey("scaleNormalAnimation")){
println("-animationDidStop- -scaleNormalAnimation-")
insideSolidLayer.transform = CATransform3DMakeScale(1, 1, 1)
shouldAnimate = true
}
}
}
}
}
最佳答案
发现问题:
func animateSolidAway(){
let scaleAnimate:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimate.fromValue = 1
scaleAnimate.toValue = 0
scaleAnimate.duration = 0
scaleAnimate.delegate = self
scaleAnimate.removedOnCompletion = false
scaleAnimate.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
insideSolidLayer.addAnimation(scaleAnimate, forKey: "scaleSmallAnimation")
}
func animateSolidIn(){
insideSolidLayer.transform = CATransform3DMakeScale(1, 1, 1)
let scaleAnimate:CABasicAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimate.fromValue = 0
scaleAnimate.toValue = 1
scaleAnimate.duration = 0
scaleAnimate.delegate = self
scaleAnimate.removedOnCompletion = false
scaleAnimate.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
insideSolidLayer.addAnimation(scaleAnimate, forKey: "scaleNormalAnimation")
}
关于swift - CABasicAnimation 看似执行两个动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27981133/
我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我遵循了教程http://gettingstartedwithchef.com/,第1章。我的运行list是"run_list":["recipe[apt]","recipe[phpap]"]我的phpapRecipe默认Recipeinclude_recipe"apache2"include_recipe"build-essential"include_recipe"openssl"include_recipe"mysql::client"include_recipe"mysql::server"include_recipe"php"include_recipe"php::modul
我在用Ruby执行简单任务时遇到了一件奇怪的事情。我只想用每个方法迭代字母表,但迭代在执行中先进行:alfawit=("a".."z")puts"That'sanalphabet:\n\n#{alfawit.each{|litera|putslitera}}"这段代码的结果是:(缩写)abc⋮xyzThat'sanalphabet:a..z知道为什么它会这样工作或者我做错了什么吗?提前致谢。 最佳答案 因为您的each调用被插入到在固定字符串之前执行的字符串文字中。此外,each返回一个Enumerable,实际上您甚至打印它。试试
我正在阅读一本关于Ruby的书,作者在编写类初始化定义时使用的形式与他在本书前几节中使用的形式略有不同。它看起来像这样:classTicketattr_accessor:venue,:datedefinitialize(venue,date)self.venue=venueself.date=dateendend在本书的前几节中,它的定义如下:classTicketattr_accessor:venue,:datedefinitialize(venue,date)@venue=venue@date=dateendend在第一个示例中使用setter方法与在第二个示例中使用实例变量之间是
如何检查Ruby文件是否是通过“require”或“load”导入的,而不是简单地从命令行执行的?例如:foo.rb的内容:puts"Hello"bar.rb的内容require'foo'输出:$./foo.rbHello$./bar.rbHello基本上,我想调用bar.rb以不执行puts调用。 最佳答案 将foo.rb改为:if__FILE__==$0puts"Hello"end检查__FILE__-当前ruby文件的名称-与$0-正在运行的脚本的名称。 关于ruby-检查是否
Unity自动旋转动画1.开门需要门把手先动,门再动2.关门需要门先动,门把手再动3.中途播放过程中不可以再次进行操作觉得太复杂?查看我的文章开关门简易进阶版效果:如果这个门可以直接打开的话,就不需要放置"门把手"如果门把手还有钥匙需要旋转,那就可以把钥匙放在门把手的"门把手",理论上是可以无限套娃的可调整参数有:角度,反向,轴向,速度运行时点击Test进行测试自己写的代码比较垃圾,命名与结构比较拉,高手轻点喷,新手有类似的需求可以拿去做参考上代码usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;u
//1.验证返回状态码是否是200pm.test("Statuscodeis200",function(){pm.response.to.have.status(200);});//2.验证返回body内是否含有某个值pm.test("Bodymatchesstring",function(){pm.expect(pm.response.text()).to.include("string_you_want_to_search");});//3.验证某个返回值是否是100pm.test("Yourtestname",function(){varjsonData=pm.response.json
我从Ubuntu服务器上的RVM转移到rbenv。当我使用RVM时,使用bundle没有问题。转移到rbenv后,我在Jenkins的执行shell中收到“找不到命令”错误。我内爆并删除了RVM,并从~/.bashrc'中删除了所有与RVM相关的行。使用后我仍然收到此错误:rvmimploderm~/.rvm-rfrm~/.rvmrcgeminstallbundlerecho'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrcecho'eval"$(rbenvinit-)"'>>~/.bashrc.~/.bashrcrbenvversions
我从用户Hirolau那里找到了这段代码:defsum_to_n?(a,n)a.combination(2).find{|x,y|x+y==n}enda=[1,2,3,4,5]sum_to_n?(a,9)#=>[4,5]sum_to_n?(a,11)#=>nil我如何知道何时可以将两个参数发送到预定义方法(如find)?我不清楚,因为有时它不起作用。这是重新定义的东西吗? 最佳答案 如果您查看Enumerable#find的文档,您会发现它只接受一个block参数。您可以将它发送两次的原因是因为Ruby可以方便地让您根据它的“并行赋