Swift95

Value​Formatters95

Environment-supplied formatting for library-owned values.

ValueFormatters95 controls localized percentage output shown by continuous progress bars and their accessibility values.

Use it

import Swift95
import SwiftUI

struct ValueFormatters95Example: View {
  private let formatters = ValueFormatters95 {
    fraction, _ in "\(Int(fraction * 100)) percent"
  }

  var body: some View {
    ProgressView95(value: 0.42)
      .valueFormatters95(formatters)
  }
}

Essential behavior

LocaleThe formatter receives the current SwiftUI Locale.
ScopeInstall it for a view subtree with valueFormatters95(_:)
DefaultThe localized formatter uses Foundation percent formatting.

Related

Open the complete ValueFormatters95 API reference →