Skip to content

Instantly share code, notes, and snippets.

@JayachandraA
Last active October 17, 2019 11:13

Revisions

  1. JayachandraA renamed this gist Oct 17, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion GigZagCardView.swift → ZigZagCardView.swift
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    class GigZagCardView: UIView {
    class ZigZagCardView: UIView {

    override func awakeFromNib() {
    layer.cornerRadius = 5
  2. JayachandraA created this gist Oct 17, 2019.
    34 changes: 34 additions & 0 deletions GigZagCardView.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    class GigZagCardView: UIView {

    override func awakeFromNib() {
    layer.cornerRadius = 5
    layer.masksToBounds = true
    backgroundColor = UIColor.clear
    }

    override func draw(_ rect: CGRect) {
    super.draw(rect)

    let noOfZigs = 25
    let path = UIBezierPath()
    let y = rect.size.height - 10
    path.move(to: CGPoint(x: 0, y: 0))
    path.addLine(to: CGPoint(x: 0, y: y))
    path.addLine(to: CGPoint(x: 0, y: y))
    let equalZig: Int = Int(rect.width/25)
    for i in 1...noOfZigs {
    path.addLine(to: CGPoint(x: CGFloat(equalZig*i), y: y-10))
    path.addLine(to: CGPoint(x: CGFloat(equalZig*i)+10, y: y))
    if i == noOfZigs{
    path.addLine(to: CGPoint(x: rect.width, y: 0))
    }
    }
    path.lineWidth = 10
    path.close()
    UIColor.white.setFill()
    UIColor.white.setStroke()
    path.lineWidth = 10
    path.stroke()
    path.fill()
    }
    }