Skip to content

Accessing Environment<Bool>'s value #8

@e1tester2019

Description

@e1tester2019

[SwiftUI] Accessing Environment's value outside of being installed on a View. This will always read the default value and will not update.

Screenshot 2022-12-03 at 11 53 10

@State private var value: Double = .zero

private var formatter: NumberFormatter {
    let f = NumberFormatter()
    f.numberStyle = .decimal
    f.maximumFractionDigits = 20
    return f
}

var body: some View {
    
    SlidingRuler(value: $value,
                 in: 0...1,
                 step: 0.1,
                 snap: .fraction,
                 tick: .fraction,
                 formatter: formatter)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions