extension UIView {
//设置虚线边框
    func setDashiedBorder() {
        let borderLayer = CAShapeLayer()
        borderLayer.bounds = self.bounds
        borderLayer.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)
        borderLayer.path = UIBezierPath(roundedRect: borderLayer.bounds, cornerRadius: 0).CGPath
        borderLayer.lineWidth = 0.5
        borderLayer.lineDashPattern = [2, 2]
        borderLayer.fillColor = UIColor.clearColor().CGColor
        borderLayer.strokeColor = UIColor(red).CGColor
        self.layer.addSublayer(borderLayer)
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-05-29
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-11
猜你喜欢
  • 2021-05-19
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-01-11
  • 2022-12-23
相关资源
相似解决方案