AuthorTravis Kirton
Tags images
Say you want to toggle a few images in your app. Instead of hiding / revealing multiple images using the hidden property, you can create a extra “container” image whose contents you set.
hidden
image.contents = anotherImage.contents
let chop = Image("chop")! let rockies = Image("rockies")! let visibleImage = Image(c4image: chop) visibleImage.constrainsProportions = true visibleImage.width = canvas.width canvas.add(visibleImage) var isFirst = true canvas.addTapGestureRecognizer { (center, location, state) -> () in if isFirst { visibleImage.contents = rockies.contents } else { visibleImage.contents = chop.contents } isFirst = !isFirst }