设为首页 加入收藏

TOP

iOS 悬浮球效果实现,悬浮按钮,拖拽,贴边,隐藏,显示,旋转屏幕适配(二)
2023-07-23 13:26:37 】 浏览:449
Tags:iOS 拖拽 贴边 隐藏 显示
[panRcognize setEnabled:YES]; [panRcognize delaysTouchesEnded]; [panRcognize cancelsTouchesInView]; [self addGestureRecognizer:panRcognize]; //监听屏幕旋转 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeStatusBarOrientation) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; } return self; } - (void)didChangeStatusBarOrientation { self.orientation = [UIApplication sharedApplication].statusBarOrientation; self.imageView.frame = CGRectMake((SCREEN_WIDTH - 50)/2, (SCREEN_HEIGHT - 50)/2, 50, 50); // DLog(@"===%zd=====%zd",[[UIDevice currentDevice] orientation],[UIApplication sharedApplication].statusBarOrientation); //请注意,UIInterfaceOrientationAndScapeLeft等于UIDeviceOrientation AndScapeRight(反之亦然)。 //这是因为向左旋转设备需要向右旋转内容。 /** UIInterfaceOrientationUnknown = UIDeviceOrientationUnknown, UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft */ /** UIDeviceOrientationUnknown, UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left UIDeviceOrientationFaceUp, // Device oriented flat, face up UIDeviceOrientationFaceDown // Device oriented flat, face down */ switch ([UIDevice currentDevice].orientation) { case UIDeviceOrientationPortraitUpsideDown: // DLog(@"设备倒垂直,home在上") [self locationChange:@"Down"]; break; case UIDeviceOrientationLandscapeLeft:{ // DLog(@"设备横屏,左转,home在右") [self locationChange:@"left"]; } break; case UIDeviceOrientationLandscapeRight:{ // DLog(@"设备横屏,右转,home在左") [self locationChange:@"right"]; } break; case UIDeviceOrientationPortrait:{ // DLog(@"设备垂直,home在下"); [self locationChange:@"Portrait"]; } break; default: break; } } //根据屏幕宽高改变按钮位置比例 - (void)locationChange:(NSString *)message{ // NSLog(@"changeHig == %f,changeWid == %f",changeHig,changeWid); if (SCREEN_HEIGHT > SCREEN_WIDTH) { //屏幕方向上 if ([message isEqualToString:@"Portrait"]) { NSLog(@"安全区在上边"); self.center = CGPointMake(changeWid * SCREEN_WIDTH, changeHig * SCREEN_HEIGHT); }else{//下 NSLog(@"安全区在下边"); self.center = CGPointMake(changeWid * SCREEN_WIDTH, changeHig * SCREEN_HEIGHT - [self vg_safeDistanceTop]); } }else{ if ([message isEqualToString:@"left"]) {//左 NSLog(@"安全区在左边"); self.center = CGPointMake(changeWid * SCREEN_WIDTH + [self vg_safeDistanceTop] + ViewSize, changeHig * SCREEN_HEIGHT); }else{//右 NSLog(@"安全区在右边"); self.center = CGPointMake(changeWid * SCREEN_WIDTH - [self vg_safeDistanceTop] - ViewSize, changeHig * SCREEN_HEIGHT); } } // NSLog(@"lastPoint == %@, self.center == %@&quo
首页 上一页 1 2 3 4 5 6 下一页 尾页 2/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇iOS 组件化实施过程 下一篇上架app store流程详解

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目