I need to determine whether a selected UIColor (picked by the user) is dark or bright, so I can change the color of a line of text that sits on top of that color, for better
For everything that's not grayish, the RGB inverse of a color is usually highly contrasted with it. The demo just inverts the color and desaturates it (converts it to a gray).
But generating a nice soothing combination of colors is quite complicated. Look at :
http://particletree.com/notebook/calculating-color-contrast-for-legible-text/