0

I want to make a tab bar with the following features:

I am creating the tab bar programmatically. Can you help me with the code?

Screenshots of the what i achieved so far : link to screenshots

Here is the code so far

class TabBarViewController: UITabBarController {

override func viewDidLoad() {
    super.viewDidLoad()

    //MARK: Initializing tab-bar viewControllers
    let prayerVC = initiateViewController.initiatePrayerVC()
    let alarmVC = initiateViewController.initiateAlarmVC()
    let settingsVC = initiateViewController.initiateSettingsVC()
    
    //MARK: tab bar item text attributes
    let attributes: [NSAttributedString.Key: Any] = [
        .font: UIFont(name: "Roboto-Medium", size: UIFont.systemFont(ofSize: 12).pointSize) as Any
]

    //MARK: edit tab bar appearance & attributes
    UITabBarItem.appearance().setTitleTextAttributes(attributes, for: .normal)
    
    //MARK: adding Title and image for each Tab bar item (viewcontroller)
    prayerVC.tabBarItem.title = text_international.prayer_times
    alarmVC.tabBarItem.title = text_international.alarm
    settingsVC.tabBarItem.title = text_international.settings

    prayerVC.tabBarItem.image = UIImage(named: "IconPrayer")
    alarmVC.tabBarItem.image = UIImage(named: "IconAlarm")
    settingsVC.tabBarItem.image = UIImage(named: "IconSettings")
    
    
    //MARK: adding View Controllers to the tab bar
    self.setViewControllers([prayerVC,alarmVC,settingsVC], animated: false)
    
    
}
Ayoub
  • 1
  • 1
  • I forgot to mention that i Use UIkit not swiftUI – Ayoub Sep 01 '23 at 11:19
  • Hi and welcome, to help you with the code we would need to have the code. Please edit your question to provide the required information. Don't forget to add what you tried and what is blocking you – La pieuvre Sep 01 '23 at 12:06
  • 1
    Read [How to ask a question](https://stackoverflow.com/help/how-to-ask) and show a minimal reproducible code that produces your issue, see: [minimal code](https://stackoverflow.com/help/minimal-reproducible-example). – workingdog support Ukraine Sep 01 '23 at 12:18
  • Tabbar item has a . selectedImage property. So what I would do is have unselected tabBar images and selected tabbar images. – OneCommentMan Sep 01 '23 at 14:14

0 Answers0