所以我正在研究一种选择器,它提醒用户平移对象而不是点击它.
以下代码是动画:
以下代码是动画:
func labelTapped(sender:UITapGestureRecognizer)->Void{ UIView.animateWithDuration(0.2,delay: 0,options: UIViewAnimationoptions.CurveEaseIn,animations: { sender.view.frame = CGRectMake(sender.view.frame.origin.x + 15,sender.view.frame.origin.y,sender.view.frame.width,sender.view.frame.height) },completion: {(value:Bool) in UIView.animateWithDuration(0.2,options: UIViewAnimationoptions.CurveEaSEOut,animations: { sender.view.frame = CGRectMake(sender.view.frame.origin.x - 15,sender.view.frame.height) },completion: {(value:Bool) in }) }) }
现在回到对象本身.我正在分配一个UITapGestureRecognizer并将其添加到对象中,但我不确定它是如何工作的,因为回到Objective-C,我们曾经做过:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTapped)];
其中不需要参数.但是在Swift中,我必须在labelTapped之后的括号中加入一个参数,因为它会在调用错误中给出参数#1的Missing参数:
let labelTap1=UITapGestureRecognizer(target: self,action: labelTapped())
我该如何解决这个问题?谢谢!