//
// ViewController.swift
// Dome2test
//
// Created by 郭文亮 on 2018/11/22.
// Copyright © 2018年 finalliang. All rights reserved.
//
import UIKit
//提供了加速值、旋转速度、三位姿态信息
import CoreMotion
class ViewController: UIViewController {
//是框架提供的一个运动管理类
var motionManager: CMMotionManager!
var label:UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label = UILabel()
label.frame = CGRect(x: 40, y: 80, width: 240, height: 90)
label.text = "waiting"
label.backgroundColor = UIColor.orange
label.numberOfLines = 3
self.view.addSubview(label)
//初始化运动管理类
motionManager = CMMotionManager()
//更新频率为10赫兹。每秒采样10次
motionManager.accelerometerUpdateInterval = 0.1
//检查传感器在设备中是否可用
if motionManager.isAccelerometerAvailable {
//使用推送的方式开始对传感器进行检测
motionManager.startAcc
IOS实用功能-陀螺仪
最新推荐文章于 2023-07-27 20:40:02 发布