Hi All,
I am new to coding and have a question that I think might be easy to answer but am not sure. I have created a Storyboard based, Tabbed application with 3 tabs.
Tab 1: Dashboard
Tab 2: Air Quality Map
Tab 3: Fire Map
For Tab 2 (Air Quality Map) I want to use the new system image aqi.medium as the tab bar image. However that image is only available in iOS 14 or later. So I created the function below to change the image based on iOS version and put it in the viewDidLoad method of the View Controller for Tab 2 (Air Quality Map). This function works however...
The problem is that when the App is first launched no tab bar image is displayed on the screen, however the tab title, "Air Quality Map", is shown. Only after the user selects the Air Quality map tab is the tab bar image displayed.
The question is how do I get the correct system tab bar image to be displayed upon app launch depending on the iOS version of the User's device?
Tab 2 (Air Quality Map) View Controller:
import Foundation
import UIKit
import MapKit
import CoreLocation
class AirQualityMapViewController: UIViewController, CLLocationManagerDelegate {
@IBOutlet weak var mapView: MKMapView!
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
checkLocationServices()
mapView.showsUserLocation = true
setTabBarImage ()
}
func setTabBarImage () {
if #available(iOS 14.0, *) {
tabBarItem.image = UIImage(systemName: "aqi.medium")
}
else {
tabBarItem.image = UIImage(systemName: "globe")
}
}
2
0
1k