Instagramのようなタブを作成するには?Instagramのようなタブを作成するには?
私は複数のUIViewController
秒をするか、または1 UIViewController
に何かをする必要がありますか?
ありがとうございました!
Instagramのようなタブを作成するには?Instagramのようなタブを作成するには?
私は複数のUIViewController
秒をするか、または1 UIViewController
に何かをする必要がありますか?
ありがとうございました!
私はgithubのからESTabbarControllerExampleをダウンロードTabbarController.Firstカスタムのようなものを作ることにESTabBarControllerExamplehttps://github.com/eggswift/ESTabBarControllerを使用することをお勧めします。私たちはいくつかのクラスレターを使う必要があります。私は一歩一歩を使用する方法について説明してみましょう:
まずCocoaPods
1オープン端子とcd ~ to your project directory
2コマンドを実行しインストールします - pod init
3あなたのpodfileがあるべきを - pod "ESTabBarController-swift"
と一緒に使用して保存します。
4そして、私たちはContent
すべての迅速なクラスを追加するとpop.framework
2 pop.frameworkを追加しないでください必要があるプロジェクトでコマンドpod install
.xcworkspace延長のオープンプロジェクトファイル
1でそれをインストールファイルを追加するを使用します。フレームワークから追加し、その他を追加する必要があります。コンテンツフォルダのすべてのファイルimport ESTabBarController_swift
StoryBordスタッフ
1では
3は、ナビゲーションコントローラのANEもESTのデモのコード例からExampleNavigationController
を追加します。 (自分で追加することもできますが)そのクラスのカスタムカスタムスウィフトクラスを設定してください。あなたが側に次のコードを実行する必要があり
コードスタッフAppDelegate.swiftで
didFinishLaunchingWithOptions
let tabBarController = ESTabBarController()
tabBarController.delegate = self
tabBarController.title = "Irregularity"
tabBarController.tabBar.shadowImage = UIImage(named: "transparent")
tabBarController.tabBar.backgroundImage = UIImage(named: "background_dark")
tabBarController.shouldHijackHandler = {
tabbarController, viewController, index in
if index == 2 {
return true
}
return false
}
tabBarController.didHijackHandler = {
[weak tabBarController] tabbarController, viewController, index in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
let alertController = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
let takePhotoAction = UIAlertAction(title: "Take a photo", style: .default, handler: nil)
alertController.addAction(takePhotoAction)
let selectFromAlbumAction = UIAlertAction(title: "Select from album", style: .default, handler: nil)
alertController.addAction(selectFromAlbumAction)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alertController.addAction(cancelAction)
tabBarController?.present(alertController, animated: true, completion: nil)
}
}
let v1 = ExampleViewController()
let v2 = ExampleViewController()
let v3 = ExampleViewController()
let v4 = ExampleViewController()
let v5 = ExampleViewController()
v1.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v2.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
v3.tabBarItem = ESTabBarItem.init(ExampleIrregularityContentView(), title: nil, image: UIImage(named: "photo_verybig"), selectedImage: UIImage(named: "photo_verybig"))
v4.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
v5.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Me", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))
tabBarController.viewControllers = [v1, v2, v3, v4, v5]
let navigationController = ExampleNavigationController.init(rootViewController: tabBarController)
tabBarController.title = "Example"
self.window?.rootViewController = navigationController
return true
あなたがのために使用することをタブバーの項目およびその他のために画像を追加資産。 あなたに役立つことを願っています。
回答ありがとうございました!しかし、それは私が意味していたようではありません。まだ画像リンクを開いていませんか?私が作ってみたいのは、赤い丸のタブです!まだアイデアはありますか? – Yutaro