我有这段代码可以快速使用加速度计,但是当条件为真时我需要动画视图,但不是动画。
我可以做些什么来制作动画。谢谢
import CoreMotion
lazy var motionManager = CMMotionManager()
override func viewDidAppear(animated: Bool) {
super.viewDidLoad()
if motionManager.accelerometerAvailable{
let queue = NSOperationQueue()
motionManager.startAccelerometerUpdatesToQueue(queue, withHandler:
{(data: CMAccelerometerData!, error: NSError!) in
if data.acceleration.x <= -0.22 && data.acceleration.x >= -0.24 {
UIView.animateWithDuration(1 ,delay: 0, options: .CurveEaseInOut | .AllowUserInteraction,
animations: {
self.text.frame = CGRectMake(100, 0, 42,21)
},
completion:{ finished in
})
}
}
)
} else {
println("Accelerometer is not available")
}
}