【UIKit】TabView
生活随笔
收集整理的這篇文章主要介紹了
【UIKit】TabView
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
【TabView】
?
?
【下面的tab欄】【?code】
【第一步】:創建一個Tabbed Application?
【第二步】:加入圖片素材。
【第三步】:創建3個有xib的類文件?FirstViewController,SecondViewController,ThirdViewController。
【第四步】:分別在FirstViewController,SecondViewController,ThirdViewController中加入下面的代碼
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; // 固定寫法if (self) {self.title = NSLocalizedString(@"關于我們", @"關于我們"); // 這個是加入標題,顯示的標題self.tabBarItem.image = [UIImage imageNamed:@"first"]; // 顯示自己圖片包中的對應的圖片}return self; }【第五步】:聲明窗口和代理方法
// 應用程序委托 @interface AppDelegate : UIResponder <UIApplicationDelegate>// 窗口 @property (strong, nonatomic) UIWindow *window;// 根視圖控制器 @property (nonatomic,retain) UITabBarController *tabController;【第六步】完善代碼
// 視圖加載完成,應用程序加載到內存后調用的方法 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// 創建窗口self.window=[[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds] autorelease];// 創建3個視圖控制器FirstViewController *viewController1=[[FirstViewController alloc] initWithNibName:nil bundle:nil];SecondViewController *viewController2=[[SecondViewController alloc] initWithNibName:nil bundle:nil];ThirdViewController *viewController3=[[ThirdViewController alloc] initWithNibName:nil bundle:nil];// 把根視圖控制器作為窗口的 第一個視圖控制器self.tabController=[[UITabBarController alloc] init];self.tabController.viewControllers=@[viewController1,viewController2,viewController3];self.window.rootViewController=self.tabController;// 顯示窗口 [self.window makeKeyAndVisible];[viewController1 release];[viewController2 release];[viewController3 release];return YES; }?
?
?
?
【創建有狀態欄的】【?Code】
【增加狀態欄】:增加前與增加后插入代碼【Code】
? ??
【第三方加入狀態標欄】:引入第三方庫【Code】
其他詳見代碼。
?// 計算當前高度
? ??CGFloat cellHeight = [tableView rectForRowAtIndexPath:indexPath].size.height;
?
轉載于:https://www.cnblogs.com/madeininfi/p/3676757.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的【UIKit】TabView的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows Server 2012
- 下一篇: Android JNI开发摘录(四)之J