Skip to content

Instantly share code, notes, and snippets.

@kidcodely
Created November 19, 2017 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kidcodely/6867ac1b667a3db8ce03d36edb0b22ab to your computer and use it in GitHub Desktop.
Save kidcodely/6867ac1b667a3db8ce03d36edb0b22ab to your computer and use it in GitHub Desktop.
Colours from images (Chameleon)
import UIKit
import ChameleonFramework
class RootViewController: UIViewController {
@IBOutlet var myImage: UIImageView!
@IBOutlet var myTitle: UILabel!
@IBOutlet var myDescription: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
myDescription.clipsToBounds = true
myDescription.layer.cornerRadius = 10.0
view.backgroundColor = ColorsFromImage(image: myImage.image!, withFlatScheme: false)[1]
myDescription.backgroundColor = ContrastColorOf(backgroundColor: view.backgroundColor!, returnFlat: false)
myDescription.textColor = ContrastColorOf(backgroundColor: myDescription.backgroundColor!, returnFlat: false)
myTitle.textColor = ContrastColorOf(backgroundColor: view.backgroundColor!, returnFlat: false)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment