0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

コードでTabBarItemの追加

Posted at

今回の内容

55578A37-B04A-4AC7-9D02-EC22CC2382D0_4_5005_c.jpeg

コードと簡単解説

  • TodayViewControllerSearchViewControllerが存在すると仮定して進めます。
  • まずは、viewControllersに入れる為のUIViewControllerを準備します。
  • 表示したいtabBarItemUITabBarItem(title:, image:, tag:)で設定します。
  • viewControllers = [todayViewController,searchViewController]Tabを設定していきます。
        let todayViewController = TodayViewController()
        todayViewController.tabBarItem = UITabBarItem(title: "Today", image: UIImage(systemName: "clock.fill"), tag: 0)
        
        let searchViewController = SearchViewController()
        searchViewController.tabBarItem = UITabBarItem(title: "Search", image: UIImage(systemName: "magnifyingglass"), tag: 1)
        
        viewControllers = [todayViewController,searchViewController]

終わり

ご指摘、ご質問などありましたら、コメントまでお願い致します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?