Skip to content

Instantly share code, notes, and snippets.

@craiggrummitt
Last active October 31, 2019 11:06
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 craiggrummitt/91e9e5527428bc6e69939079865e3a28 to your computer and use it in GitHub Desktop.
Save craiggrummitt/91e9e5527428bc6e69939079865e3a28 to your computer and use it in GitHub Desktop.
Renders a tiled image in a view. Also renders in the storyboard.
@IBDesignable
class TiledImageView:UIView {
@IBInspectable var image:UIImage?
override func draw(_ rect: CGRect) {
guard let image = image else {return}
UIColor(patternImage: image).setFill()
let path = UIBezierPath(rect: rect)
path.fill()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment