Skip to content

Instantly share code, notes, and snippets.

@simonwuyts
Created June 5, 2017 13:05
Show Gist options
  • Save simonwuyts/b280f8ae8dcf47fcb484633b4c256fb4 to your computer and use it in GitHub Desktop.
Save simonwuyts/b280f8ae8dcf47fcb484633b4c256fb4 to your computer and use it in GitHub Desktop.
Paint
// Shadow Layer
let shadowShape = CAShapeLayer()
shadowShape.path = bubblePath.cgPath
shadowShape.fillColor = fillColor.cgColor
shadowShape.shadowColor = shadowColor.cgColor
shadowShape.shadowOffset = CGSize(width: CGFloat(shadowOffsetX), height: CGFloat(shadowOffsetY))
shadowShape.shadowRadius = CGFloat(shadowBlur)
shadowShape.shadowOpacity = 0.8
// Border Layer
let borderShape = CAShapeLayer()
borderShape.path = bubblePath.cgPath
borderShape.fillColor = fillColor.cgColor
borderShape.strokeColor = borderColor.cgColor
borderShape.lineWidth = CGFloat(borderWidth*2)
// Fill Layer
let fillShape = CAShapeLayer()
fillShape.path = bubblePath.cgPath
fillShape.fillColor = fillColor.cgColor
// Add Sublayers
self.layer.insertSublayer(shadowShape, at: 0)
self.layer.insertSublayer(borderShape, at: 0)
self.layer.insertSublayer(fillShape, at: 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment