UIAppearance Swift 4 UIAppearance Swift 4 ios ios

UIAppearance Swift 4


Right - the current Swift 4 conversion tool (as of Xcode 9 Beta 4) gets a little carried away.

I was able to fix the problem quickly by reverting the UIAppearance conversion code, then updating the individual attributes.

For example, in Swift 3 I had:

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.white], for: .selected)

Xcode "helped" me out by changing it to:

UIAppearance.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white], for: .selected)

I was able to quiet the errors by half-reverting, to:

UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white], for: .selected)