私は加速度計を使用するためにこのコードを迅速に持っていますが、条件が true のときにビューをアニメーション化する必要がありますが、アニメーション化する必要はありません。
アニメーション化するにはどうすればよいですか。ありがとう
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")
}
}