Skip to content

FB7551832: SwiftUI Color should have color manipulation methods that return a new Color #85

@sindresorhus

Description

@sindresorhus
  • Date: 2020-01-26
  • Resolution: Open
  • Area: SwiftUI Framework
  • OS: macOS 10.15.2
  • Type: Suggestion

Description

Currently, there are many View methods that you can use on a Color. For example, .colorInvert(), .contrast(), .hueRotation(). The problem is that they return a some View instead of a new Color, so it's impossible to use them with methods that only accepts a Color.

It would be nice if there were Color-specific overloads of these methods that return a Color instead of a some View when used on a Color.

My specific use-case is that I want to invert Color.primary and use it in .stroke(), but .stroke() accepts a ShapeStyle (which Color conforms to, but View does not) and Color.primary.colorInvert() returns a some View.

This is what I would want:

Circle().strokeBorder(Color.primary.colorInvert().opacity(0.3), lineWidth: 0.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions