日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

如何在iOS上实现苹果电脑最小化窗口时的“神奇效果”(即吸入吸出效果在iPhone上的实现)

發(fā)布時(shí)間:2024/1/1 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何在iOS上实现苹果电脑最小化窗口时的“神奇效果”(即吸入吸出效果在iPhone上的实现) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.


先看一下效果




1.首先創(chuàng)建一個(gè)新工程,結(jié)構(gòu)是TabbarViewController+UIViewController*4

@interface AppDelegate ()<UITabBarControllerDelegate> {UITabBarController *tabBarController;NSMutableArray *isInArray; // 標(biāo)記動(dòng)畫(huà)方向UIViewController *controller; //一個(gè)全局VC }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {////初始化window設(shè)置其背景圖//self.window = [[UIWindow alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH_NEW, SCREEN_HEIGHT_NEW)];UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"b%d",5]]];imageView.frame = self.window.frame;[self.window addSubview:imageView];////array:存放4個(gè)透明VC(為了正常顯示系統(tǒng)的TabBar和其點(diǎn)擊事件)。第一個(gè)VC默認(rèn)設(shè)置微信截圖//NSMutableArray *array = [[NSMutableArray alloc]initWithCapacity:4];NSArray *titleArray = @[@"微信",@"通訊錄",@"發(fā)現(xiàn)",@"我"];for(int i = 0 ; i < 4 ; i ++){UIViewController *controller_ = [[UIViewController alloc]init];[array addObject:controller_];UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:titleArray[i] image:[UIImage imageNamed:[NSString stringWithFormat:@"%d",i+1]] tag:i];controller_.tabBarItem = item;if (i == 0) {UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"b%d",i+1]]];imageView.frame = self.window.frame;[controller_.view addSubview:imageView];}}tabBarController = [[UITabBarController alloc]init];tabBarController.viewControllers = array;tabBarController.delegate = self;self.window.rootViewController = tabBarController;[self.window makeKeyAndVisible];////全局VC,展示不同截圖//controller = [[UIViewController alloc]init];////動(dòng)畫(huà)方向//isInArray = @[[NSNumber numberWithBool:NO],[NSNumber numberWithBool:YES],[NSNumber numberWithBool:YES],[NSNumber numberWithBool:YES]].mutableCopy;return YES; }
2 實(shí)現(xiàn)UITabBarControllerDelegate

-(void)tabBarController:(UITabBarController *)tabBarControllerLocal didSelectViewController:(UIViewController *)viewController{NSLog(@"%lu",(unsigned long)tabBarController.selectedIndex);////tabBarItem點(diǎn)擊后 就把默認(rèn)圖移除//[tabBarController.viewControllers[0].view removeAllSubviews];////設(shè)置對(duì)應(yīng)截圖//UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"b%lu",tabBarController.selectedIndex+1]]];imageView.frame = self.window.frame;[controller.view addSubview:imageView];[tabBarController.view insertSubview:controller.view belowSubview:tabBarController.tabBar];////開(kāi)始動(dòng)畫(huà)//[self genieToRect:CGRectMake(0, 0, 0, 0) edge:BCRectEdgeTop ];}3 實(shí)現(xiàn)動(dòng)畫(huà)方法 。從github上下載UIView+Genie這個(gè)開(kāi)源代碼,然后引入U(xiǎn)IView+Genie。地址https://github.com/Ciechan/BCGenieEffect/

- (void) genieToRect: ( CGRect)rect2 edge: (BCRectEdge) edge {dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{////isin = NO執(zhí)行的是向下回收的動(dòng)畫(huà) 一個(gè)頁(yè)面下來(lái) 其他的應(yīng)該都下去//////不同的起始位置//CGRect rect = CGRectMake(SCREEN_WIDTH_NEW/4* tabBarController.selectedIndex, SCREEN_HEIGHT_NEW +100, SCREEN_WIDTH_NEW / 5, 20);UIView *tranView = controller.view;BOOL isin = [isInArray[tabBarController.selectedIndex] boolValue];if (isin == NO) {////向下//for (int i = 0; i < isInArray.count; i ++) {if (i != tabBarController.selectedIndex) {[isInArray replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];tabBarController.viewControllers[i].view.frame = CGRectMake(SCREEN_WIDTH_NEW/4* i, SCREEN_HEIGHT_NEW +20, SCREEN_WIDTH_NEW/5, 20);;}}}else{////向上//for (int i = 0; i < isInArray.count; i ++) {if (i != tabBarController.selectedIndex) {[isInArray replaceObjectAtIndex:i withObject:[NSNumber numberWithBool:YES]];tabBarController.viewControllers[i].view.frame = CGRectMake(SCREEN_WIDTH_NEW/4* i, SCREEN_HEIGHT_NEW +20, SCREEN_WIDTH_NEW/5, 20);;}}}NSTimeInterval duration = 0.5;tabBarController.tabBar.userInteractionEnabled = NO;CGRect endRect = rect;if (isin) {[tranView genieOutTransitionWithDuration:duration startRect:endRect startEdge:edge completion:^{BOOL isInLocal = [isInArray[tabBarController.selectedIndex] boolValue];[isInArray replaceObjectAtIndex:tabBarController.selectedIndex withObject:[NSNumber numberWithBool:!isInLocal]];tabBarController.tabBar.userInteractionEnabled = YES;}];} else {NSLog(@"xia");[tranView genieInTransitionWithDuration:duration destinationRect:endRect destinationEdge:edge completion:^{BOOL isInLocal = [isInArray[tabBarController.selectedIndex] boolValue];[isInArray replaceObjectAtIndex:tabBarController.selectedIndex withObject:[NSNumber numberWithBool:!isInLocal]];tabBarController.tabBar.userInteractionEnabled = YES;}];}}); }

demo 下載 http://download.csdn.net/detail/qq_15509071/9824864




總結(jié)

以上是生活随笔為你收集整理的如何在iOS上实现苹果电脑最小化窗口时的“神奇效果”(即吸入吸出效果在iPhone上的实现)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。