Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to grab and save an image from a default UIButton
override func viewDidLoad() {
let fileName = "infoLight.png"
let b = UIButton.buttonWithType(UIButtonType.InfoLight) as! UIButton
let img = b.imageForState(.Normal)
let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let dir = (paths[0] as! String)+"/"+fileName
UIImagePNGRepresentation(img).writeToFile(dir, atomically: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment