swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.33k stars 10.34k forks source link

[SR-5492] UIAppearance Swift 4 #48064

Closed swift-ci closed 7 years ago

swift-ci commented 7 years ago
Previous ID SR-5492
Radar None
Original Reporter Ronaldoh1 (JIRA User)
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 034dbd3b25f23bf4ec1d3caf11d238b7

Issue Description:

While updating to Swift 4. We encountered a problem with UIAppearance.

The compiler provides the following error:

Static member 'appearance' cannot be used on protocol metatype 'UIAppearance.Protocol'

UIAppearance.appearance().setTitleTextAttributes([NSAttributedStringKey.font
.NSAttributedStringKey.font: font], for: .selected)

belkadan commented 7 years ago

UIAppearance is a protocol. You're supposed to call its methods on types that implement that protocol.

swift-ci commented 7 years ago

Comment by Ronald Hernandez (JIRA)

@belkadan duh. Thanks man.

regexident commented 7 years ago

I'm not sure I'd consider this resolved or an invalid bug report.

The Swift Migrator replaces `UITabBar.appearance()` (and the like) with `UIAppearance.appearance()` during migration to Swift 4, which then leads to this compiler error.

Reproduce via:

1. Create iOS project

  1. Change Swift Version to v3.2
  2. Anywhere in the project add this: