Post

Replies

Boosts

Views

Activity

Reply to WeatherKit not showing Temp Correctly on device
Hi.. I also ran into this issue with SwiftUI and the iOS 16 SDK, and the fix was to specify the format. At that time just calling out the measurement width to be narrow, resolved the issue. But... It came up again with iOS 17 SDK. Below is an example of what I did to fix the issue. The main thing is to look at how the format for measurement is configured. weather.currentWeather.temperature.formatted(.measurement(width: .narrow, usage: .weather, numberFormatStyle: .number.precision(.fractionLength(0)))))
Topic: App & System Services SubTopic: General Tags:
Jun ’23
Reply to WeatherKit Temperature formatting on Mac
Thanks for helping Claude, the code there actually also shows the value in addition to the ° symbol. The .narrow just takes away the localized label, i.e. "F or C". taking out the .narrow would write 99°F for instance. Taking away the .formatted() option leaves the raw NSMeasurement object. You can add .description to the end of the temperature, and it will return the value in Celsius, but this description cannot be formatted from what I can find. Which is what led me to the code below. Hope that helps. Thanks again. The full code to write that text is Text("\(weather.currentWeather.temperature.formatted(.measurement(width: .narrow)))") .font(.system(.largeTitle, design: .rounded)) .fontWeight(.bold) .foregroundColor(Color.white)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22