Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Objective-C HEX Color String Parser

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 HEXParser.h
Octocat-spinner-32 HEXParser.m
Octocat-spinner-32 README.markdown
README.markdown

HEXParser

This is a helper method for determining if a string is a valid HEX color string. If it isn't it will convert it.

  • gfe7t Becomes #FFEE77
  • #000000000 > #000000
  • 0ffggk > #00FFFF
  • # > #000000
  • "" > #000000
  • fjfkdslafjdk > #FFDAFD
  • fkdl > #FD0000

Behavior

Some unusual/odd behaviors.

  • If the string is to long, it will be truncated.

  • If the string is to short it will have 0s added to the end.

  • If the string contains 3 values they will be doubled.

  • If a character isn't a valid hex value 1-9 A-F it will be dropped, and all the other characters will slide in and take it's palace.

Feel free to ask me questions on Twitter / @SkylarSch

Something went wrong with that request. Please try again.