项目作者: KenanAtmaca

项目描述 :
İOS CoreMotion Helper Class
高级语言: Swift
项目地址: git://github.com/KenanAtmaca/KMotionHelper.git
创建时间: 2017-09-04T20:08:42Z
项目社区:https://github.com/KenanAtmaca/KMotionHelper

开源协议:

下载


KMotionHelper

İOS CoreMotion Helper Class

alt tag

Use

  1. var helper = KMotionHelper.shared
Sensor Actions
  1. helper.accelerometer { (acceloremeter) in
  2. // Actions
  3. }
  4. helper.gyro { (gyro) in
  5. // Actions
  6. }
  7. helper.magnetometer { (magnometer) in
  8. // Actions
  9. }
  10. helper.motion { (motion) in
  11. // Actions
  12. }
Pedometer & Activity
  1. helper.startPedometer { (pedo) in
  2. self.pedoLabel.text = "\(pedo.numberOfSteps)"
  3. }
  4. helper.startActivity { (acc) in
  5. if acc.stationary {
  6. self.view.backgroundColor = UIColor.lightGray
  7. } else if acc.walking {
  8. self.view.backgroundColor = UIColor.green
  9. }
  10. }
Helpful functions
  1. scale(data:Double) -> CGFloat
  2. rotation(data: CMRotationRate) -> Double
  3. degree(radian:Double) -> Double
  4. magnitude(from attitude: CMAttitude) -> Double
  • [X] info.plist select Privacy settings motion usage.