IOS加速器的使用


#pragma mark - 
#pragma mark - 加速器代理方法
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
	float xx = -[acceleration x];
	float yy = [acceleration y];
	float angle = atan2(yy, xx);
	[arrow setTransform:CGAffineTransformMakeRotation(angle)];
    NSLog(@"加速器");
}


- (void) viewDidLoad
{
	self.navigationController.navigationBar.tintColor = COOKBOOK_PURPLE_COLOR;
    
    //拿到加速器,设置代理
	[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}





你可能感兴趣的:(加速器)