Skip to content

CaedmonMyers/ColorHex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ColorHex

Static Badge

ColorHex is a simple package for Swift apps. It allows you to easily work with hex codes in your app.

Installation

To install with Swift Package Manager, add the following as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/CaedmonMyers/ColorHex.git", from: "1.0.1")
]

Alternatively, you can install the package by downloading the ColorHex.swift and adding it to your project.

Usage

Show a color view from a hex string:

import ColorHex

struct ContentView: View {
    var body: some View {
        Color(hex: "FFFFFF")
    }
}

Use .toHex() with a color picker:

ColorPicker("Color Picker", selection: $color)
.onChange(of: color) { oldValue, newValue in
let uiColor = UIColor(newValue)
let hexString = uiColor1.toHex()

spaces[selectedSpaceIndex].startHex = hexString
}

Functions

  • Color(hex: "FFFFFF"): View
  • .toHex(): String?

You will need to properly handle the optional value for the .toHex() function in the event the conversion fails.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages