Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattrobmattrob/02b15dcd2c4556d314c9c466e823f471 to your computer and use it in GitHub Desktop.
Save mattrobmattrob/02b15dcd2c4556d314c9c466e823f471 to your computer and use it in GitHub Desktop.
extension BubbleView {
/// Draws a set of stripes across the view up from bottom left
/// to top right at a 45 degree angle. The stripes will be
/// `stripeWidth` wide and have `stripeWidth` between them.
func drawStripes(in bubbleBounds: CGRect,
stripeColor: UIColor,
stripeWidth: CGFloat) {...}
}
final class BubbleView: UIView {
override func draw(_ rect: CGRect) {
drawBubble(in: bounds, bubbleColor: .orange)
// Arbitrarily size the size as 1/10th the maximum radius.
let stripeWidth = bounds.width / 2.0 * 0.1
drawStripes(in: bounds,
stripeColor: UIColor.black.withAlphaComponent(0.3),
stripeWidth: stripeWidth)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment