On iOS 27, selected.badgeBackgroundColor is ignored and the selected tab's badge uses the normal colour instead. This happens on both iPhone Duo (iOS 27.1) and iPhone 18 Pro (iOS 27.0), while iOS 26.2 and 18.6 work correctly.
Filled as FB25014925
Repro:
import UIKit
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let config = UISceneConfiguration(name: nil, sessionRole: connectingSceneSession.role)
config.delegateClass = SceneDelegate.self
return config
}
}
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let windowScene = scene as? UIWindowScene else { return }
let purple = UIColor(red: 0xb0 / 255.0, green: 0x7e / 255.0, blue: 0xff / 255.0, alpha: 1)
let blue = UIColor(red: 0x00 / 255.0, green: 0xa9 / 255.0, blue: 0xf0 / 255.0, alpha: 1)
// Tab1: badge "1", no appearance.
let tab1 = makeTab(title: "Tab1", badge: "1", text: "Tab1\nNo appearance set")
// Tab3: badge "NEW!", normal PURPLE, selected BLUE.
let tab3 = makeTab(
title: "Tab3", badge: "NEW!",
text: "Tab3\nnormal badgeBackgroundColor: PURPLE\nselected badgeBackgroundColor: BLUE")
let appearance = UITabBarAppearance()
appearance.stackedLayoutAppearance.normal.badgeBackgroundColor = purple
appearance.stackedLayoutAppearance.selected.badgeBackgroundColor = blue
tab3.tabBarItem.standardAppearance = appearance
let tabBarController = UITabBarController()
tabBarController.viewControllers = [tab1, tab3]
tabBarController.selectedIndex = ProcessInfo.processInfo.arguments.contains("-selectFirst") ? 0 : 1
let window = UIWindow(windowScene: windowScene)
window.rootViewController = tabBarController
self.window = window
window.makeKeyAndVisible()
}
private func makeTab(title: String, badge: String, text: String) -> UIViewController {
let vc = UIViewController()
vc.view.backgroundColor = .systemBackground
vc.tabBarItem = UITabBarItem(title: title, image: UIImage(systemName: "star"), selectedImage: nil)
vc.tabBarItem.badgeValue = badge
let label = UILabel()
label.text = text
label.numberOfLines = 0
label.textAlignment = .center
label.translatesAutoresizingMaskIntoConstraints = false
vc.view.addSubview(label)
NSLayoutConstraint.activate([
label.centerXAnchor.constraint(equalTo: vc.view.centerXAnchor),
label.centerYAnchor.constraint(equalTo: vc.view.centerYAnchor),
label.widthAnchor.constraint(lessThanOrEqualTo: vc.view.widthAnchor, constant: -32),
])
return vc
}
}