A format style that converts between decimal percentage values and their textual representations.
Members (15)
get · iOS 15.0+
attributed
TypeScript
get attributed(): Decimal_FormatStyle_Attributed
Swift declaration
var attributed: Decimal.FormatStyle.Attributed { get }
An attributed format style based on the decimal percent format style.
Use this modifier to create a ``Decimal/FormatStyle/Attributed`` instance, which formats
values as ``AttributedString`` instances. These attributed strings contain attributes from
the ``AttributeScopes/FoundationAttributes/NumberFormatAttributes`` attribute scope. Use
these attributes to determine which runs of the attributed string represent different
parts of the formatted value.
get · iOS 15.0+
parseStrategy
TypeScript
get parseStrategy(): Decimal_ParseStrategy<Decimal_FormatStyle_Percent>
Swift declaration
var parseStrategy: Decimal.ParseStrategy<Decimal.FormatStyle.Percent> { get }
Modifies the format style to use the specified decimal separator display strategy.
- Parameter strategy: The decimal separator display strategy to apply to the format style.
- Returns: A decimal percent format style modified to use the specified decimal separator display strategy.
Modifies the format style to use the specified sign display strategy for displaying or omitting sign symbols.
- Parameter strategy: The sign display strategy to apply to the format style.
- Returns: A decimal percent format style modified to use the specified sign display strategy.
Modifies the format style to use the specified scale.
- Parameter multiplicand: The multiplicand to apply to the format style.
- Returns: A decimal percent format style modified to use the specified scale.
method · iOS 15.0+
format
TypeScript
format(value: Decimal): string
Swift declaration
func format(_ value: Decimal) -> String
Formats a decimal value as a percentage, using this style.
- Parameter value: The decimal value to format.
- Returns: A string representation of `value` formatted as a percentage according to the style's configuration.
get · iOS 15.0+
locale
TypeScript
get locale(): Locale
Swift declaration
var locale: Locale
The locale of the format style.
Use the ``locale(_:)`` modifier to create a copy of this format style with a different locale.
set · iOS 15.0+
locale
TypeScript
set locale(value: Locale)
Swift declaration
var locale: Locale
The locale of the format style.
Use the ``locale(_:)`` modifier to create a copy of this format style with a different locale.
Creates a decimal percent format style that uses the given locale.
- Parameter locale: The locale to use when formatting or parsing decimal values.
Defaults to `Locale.autoupdatingCurrent`.
Modifies the format style to use the specified locale.
- Parameter locale: The locale to apply to the format style.
- Returns: A decimal percent format style modified to use the provided locale.
Modifies the format style to use the specified rounding rule and increment.
- Parameters:
- rule: The rounding rule to apply to the format style.
- increment: A multiple by which the formatter rounds the fractional part. The formatter
produces a value that is an even multiple of this increment. If this parameter is
`nil` (the default), the formatter doesn't apply an increment.
- Returns: A decimal percent format style modified to use the specified rounding rule and increment.
Modifies the format style to use the specified grouping.
- Parameter group: The grouping to apply to the format style.
- Returns: A decimal percent format style modified to use the specified grouping.
Modifies the format style to use the specified notation.
- Parameter notation: The notation to apply to the format style.
- Returns: A decimal percent format style modified to use the specified notation.
Matches the input string within the specified bounds, beginning at the given index.
Don't call this method directly. Regular expression matching and capture calls it
automatically when matching substrings.
- Parameters:
- input: An input string to match against.
- index: The index within `input` at which to begin searching.
- bounds: The bounds within `input` in which to search.
- Returns: The upper bound where the match terminates and a matched instance, or `nil` if there isn't a match.
Modifies the format style to use the specified precision.
- Parameter p: The precision to apply to the format style.
- Returns: A decimal percent format style modified to use the specified precision.