<>ios14.3开发之使用纯代码创建UITabbarController

这里我们IOS版本14.3。Xcode
版本选择的是。12.3版本;来自apple最新的xcode版本,该版本支持最新的swift语法和最少的bug,支持新的api函数。
数风流人物,还看今朝。尽量苹果之前的ios系统很完美,都是苹果最近总是推陈出新,我们必须学习和使用新的ios系统。源码请在我的主页 资源库查找。

scene 场景 两个文件要删除 .m 和.h 文件全部干掉
main.stroyboard 删除,plist里面该删除的都要删除,
delegate。h 头文件 增加一句代码
@property(nonatomic,strong)UIWindow *windows; // 使用strong 进行强引用
AppDelegate.m 把无用的多余的代码进行注销掉,或者删掉;这样就可以了
设置window的根控制器为纯代码的创建的tabbarViewController
核心代码如下;
报错不要着急,搜一搜文档,务必学会。
// // AppDelegate.m // 23-tabbarController // // Created by 鲁军 on 2021/2/14. //
#import "AppDelegate.h" @interface AppDelegate () @end @implementation
AppDelegate- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point
for customization after application launch. self.window =[[UIWindow alloc]
initWithFrame:[UIScreen mainScreen].bounds]; UITabBarController *tab =[[
UITabBarController alloc] init]; UIViewController *v1 = [[UIViewController alloc
]init]; UIViewController *v2 = [[UIViewController alloc]init]; UIViewController
*v3 = [[UIViewController alloc]init]; v1.view.backgroundColor=[UIColor grayColor
]; v2.view.backgroundColor=[UIColor orangeColor]; v3.view.backgroundColor=[
UIColor blueColor]; v1.tabBarItem.title = @"消息"; v2.tabBarItem.title = @"联系人";
v3.tabBarItem.title = @"设置"; //tab_recent_nor tab_buddy_nor tab_me_nor v1.
tabBarItem.image=[UIImage imageNamed:@"tab_recent_nor"]; v2.tabBarItem.image=[
UIImage imageNamed:@"tab_buddy_nor"]; v3.tabBarItem.image=[UIImage imageNamed:
@"tab_me_nor"]; v1.tabBarItem.badgeValue = @"999"; [tab addChildViewController:
v1]; [tab addChildViewController:v2]; [tab addChildViewController:v3]; self.
window.backgroundColor = [UIColor greenColor]; self.window.rootViewController =
tab; [self.window makeKeyAndVisible]; // NSLog(@"%@",tab.tabBar); //<UITabBar:
0x7fa179c077f0; frame = (0 519; 320 49); autoresize = W+TM; gestureRecognizers
= <NSArray: 0x600003b526d0>; layer = <CALayer: 0x600003551e40>> return YES; }
@end

技术
今日推荐
PPT
阅读数 121
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信