如何製作類似Instagram的標籤?如何製作一個類似Instagram的選項卡?
我需要讓多個UIViewController
S或使事情在一個UIViewController
?
在此先感謝您的幫助!
如何製作類似Instagram的標籤?如何製作一個類似Instagram的選項卡?
我需要讓多個UIViewController
S或使事情在一個UIViewController
?
在此先感謝您的幫助!
我建議使用ESTabBarControllerExamplehttps://github.com/eggswift/ESTabBarController來製作那種自定義TabbarController.First從github下載ESTabbarControllerExample。我們需要使用一些類信函。讓我來介紹一下如何使用分步:
首先安裝的CocoaPods
1個打開終端和cd ~ to your project directory
2執行命令 - pod init
3你podfile應與使用 - pod "ESTabBarController-swift"
並保存
4用命令安裝pod install
.xcworkspace擴展的開放項目文件
1在項目中,我們需要添加Content
所有SWIFT類和pop.framework
2不要添加pop.framework使用添加文件到。您必須從Framework添加並添加其他。
3在內容文件夾中的所有文件import ESTabBarController_swift
StoryBord東西
1添加導航控制器ANE也從EST演示示例代碼添加ExampleNavigationController
。 (你也可以自己添加),但是確保你設置了它的導航類自定義swift類。
代碼的東西在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
添加映像進行的TabBar物品等要使用在資產。 希望對你有所幫助。
感謝您的回答!但它似乎並不是我的意思。你有沒有打開圖片鏈接?我想要做的是紅圈的標籤!你還有什麼想法嗎? – Yutaro