iOS-新手引导页+标签控制器
来源:互联网 发布:软件实施全过程 编辑:程序博客网 时间:2024/06/07 22:53
AppDelegate.h
#import "ViewController.h"#import "MenuViewController.h"@interface AppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonatomic) UIWindow *window;@property (readonly, strong) NSPersistentContainer *persistentContainer;@property (nonatomic,strong)MenuViewController *vc;@property (nonatomic,strong)UITabBarController *tabBarCtl;//标签栏控制器
AppDelegate.m
#import "GuideViewController.h"#import "MenuViewController.h"#import "MeViewController.h"#import "TopicViewController.h"@interface AppDelegate ()@end@implementation AppDelegate//私有方法,用于生成一个导航控制器- (UINavigationController *)createNavigationWithController:(UIViewController *)vc title:(NSString *)title image:(NSString *)imgName selectImage:(NSString *)selectImgName{ UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc]; vc.navigationItem.title = title; nav.tabBarItem = [[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:imgName] selectedImage:[UIImage imageNamed:selectImgName]]; return nav;}//标签栏控制器- (UITabBarController *)tabBarCtl{ if (!_tabBarCtl) { _tabBarCtl = [[UITabBarController alloc]init]; self.tabBarCtl.tabBar.tintColor = [UIColor blackColor]; UINavigationController *homeNav = [self createNavigationWithController:[[MenuViewController alloc]init] title:@"头条" image:@"main_bottom_tab_recipe_gray_25x25_" selectImage:@"main_bottom_tab_recipe_red_25x25_"]; UINavigationController *selectNav = [self createNavigationWithController:[[TopicViewController alloc]init] title:@"小组" image:@"main_bottom_tab_pai_gray_25x25_" selectImage:@"main_bottom_tab_pai_red_25x25_"]; UINavigationController *myNav = [self createNavigationWithController:[[MeViewController alloc]init] title:@"我的" image:@"main_bottom_tab_user_gray_25x25_" selectImage:@"main_bottom_tab_user_red_25x25_"]; _tabBarCtl.viewControllers = @[homeNav,selectNav,myNav]; [[UITabBar appearance] setTintColor:[UIColor colorWithRed:252/255.0 green:104/255.0 blue:106/255.0 alpha:1]]; //设置导航的背景颜色 [UINavigationBar appearance].barTintColor=[UIColor colorWithRed:252/255.0 green:104/255.0 blue:106/255.0 alpha:1]; } return _tabBarCtl;}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. GuideViewController *guideVC = [[GuideViewController alloc]init]; self.vc = [[MenuViewController alloc]init]; //第一次运行app if (![[NSUserDefaults standardUserDefaults]objectForKey:NOT_FIRST_LANUCH]) { self.window.rootViewController = guideVC; } //非首次运行app else{ //获取当前的版本号 //获取持久化的版本号数据 NSString *savedVersion = [[NSUserDefaults standardUserDefaults]objectForKey:NOT_FIRST_LANUCH]; //判断版本号是否一致 if ([savedVersion isEqualToString:VERSION_CURRENT]) { //没有更新 self.window.rootViewController = self.vc; } else{ //更新了 self.window.rootViewController = guideVC; } } return YES;}
GuideViewController.m
#import "ImageScrollView.h"#import "AppDelegate.h"@interface GuideViewController ()<ImageScrollViewDelegate>@end@implementation GuideViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor whiteColor]; NSArray *imgArr = @[@"新手引导页5.jpg",@"新手引导页4.jpg",@"首页.jpg"]; ImageScrollView *imgScrView = [[ImageScrollView alloc]initWithFrame:CGRectNull style:ImageScrollType_Guide images:imgArr confirmBtnTitle:@"立即体验" confirmBtnTitleColor:[UIColor redColor] confirmBtnFrame:CGRectMake(230, 10, 100, 40) autoScrollTimeInterval:0 delegate:self]; [self.view addSubview:imgScrView]; [imgScrView addPageControlToSuperView:self.view];}#pragma mark -ImageScrollViewDelegate- (void)experienceDidHandle{ //获取当前的版本号,持久化 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; [ud setObject:VERSION_CURRENT forKey:NOT_FIRST_LANUCH]; [ud synchronize]; //切换窗口的根视图控制器 AppDelegate *app = App_Delegate; app.window.rootViewController = app.vc;}
MenuViewController.m
self.view.backgroundColor = [UIColor whiteColor]; AppDelegate *app = App_Delegate; app.window.rootViewController = app.tabBarCtl;
阅读全文
0 0
- iOS-新手引导页+标签控制器
- iOS新手引导页的实现,源码
- iOS 新手引导页面
- ios自定义标签控制器
- 新手引导页-ViewPager
- 新手引导页
- 新手引导页
- IOS项目新手引导页图片适配方案
- ios 三级控制器 标签栏
- IOS--UI--LessonUITabBarController 标签控制器
- iOS UI初级-标签控制器
- iOS-创建 tabBar(标签控制器)
- ViewPager+app新手引导页
- 新手引导
- 新手引导
- 新手引导
- 新手引导
- iOS导航控制器和标签栏控制器的结合
- Delphi整理五(枚举、子界、集合)
- 奇异值分解(SVD)原理详解及推导
- Fresco
- shiping
- thinkphp 多图和单图上传处理 (我认为这个方法更好吧 比我以前写的 高效了不少)
- iOS-新手引导页+标签控制器
- 转行人士如何在人工智能领域保持一定的竞争力?
- ubuntu14.04 英伟达显卡 安装cuda 8 解决循环登录问题
- 在训练网络的时候,验证集误差是比测试集误差低还是高? | 社区问答
- 线程 猜数字
- EventBus 3.0实现Activity和fragment通信、fragment和fragment通信
- 10分钟搞懂神经网络的容量 | Neural Networks #5
- caffe model转json
- Hibernate 二级缓存