Using the device's onboard gyroscope can be achieved, when you rotate the phone screen, the inside of the screen will not be updated with the view to move to balance the physical movement.
The following example performs this operation using a small number of simple geometric transformations. He builds a motion manager, subscribes to device motion updates, and then applies image transformations based on the swing, forward tilt, and sway angle of the motion manager return.
@implementationtestbedviewcontroller{Cmmotionmanager*Motionmanager; Uiimageview*ImageView;}- (void) shutdownmotionmanager{NSLog (@"shutting down motion manager"); [Motionmanager stopdevicemotionupdates]; Motionmanager=Nil;}- (void) establishmotionmanager{if(Motionmanager) [self shutdownmotionmanager]; NSLog (@"establishing motion manager"); //Establish the motion managerMotionmanager =[[Cmmotionmanager alloc] init]; if(motionmanager.devicemotionavailable) [Motionmanager startdevicemotionupdatestoqueue:[nsoperationqueue Currentqueue] Withhandler:^ (Cmdevicemotion *motion, Nserror *error) {Catransform3d transform; Transform= Catransform3dmakerotation (Motion.attitude.pitch,1,0,0); Transform= Catransform3drotate (transform, Motion.attitude.roll,0,1,0); Transform= Catransform3drotate (transform, Motion.attitude.yaw,0,0,1); ImageView.layer.transform=transform; }];}- (void) Viewdidappear: (BOOL) animated{nsstring*imagename = Is_ipad?@"Ipadart.png":@"Iphoneart.png"; UIImage*image =[UIImage Imagenamed:imagename]; ImageView=[[Uiimageview alloc] initwithimage:image]; Imageview.center=Rectcenter (self.view.bounds); [Self.view Addsubview:imageview];}- (void) loadview{[Super Loadview]; Self.view.backgroundColor=[Uicolor Whitecolor];}
Device-specific development for IOS: Get and use device posture (Control 3d object display via phone direction)