mariia
6/12/2019 - 7:26 AM

Parallellogram UIView

class TiltedView: UIView {
    
    init() {
        super.init(frame: .zero)
        self.backgroundColor = UIColor.clear
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func draw(_ rect: CGRect) {
        let path = UIBezierPath()
        
        path.move(to: CGPoint(x: bounds.minX, y: bounds.minY + BrandBackgroundOffset.Offset)) //top left corner
        path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.minY)) //top right corner
        path.addLine(to: CGPoint(x: bounds.maxX, y: bounds.maxY)) //bottom right corner
        path.addLine(to: CGPoint(x: bounds.minX, y: bounds.maxY)) //bottom left corner
        
        // Close the path. This will create the last line automatically.
        path.close()
        UIColor.fr_darkIndigo.setFill()
        path.fill()
    }
    
}