这个渐变是我想在虚线UIBezierPath上实现的。试过这段代码没有成功。letgradient=CAGradientLayer()gradient.frame=outerPath.boundsgradient.colors=[UIColor.red.cgColor,UIColor.yellow.cgColor]//maskletshapeMask=CAShapeLayer()shapeMask.path=outerPath.cgPathself.insertSublayer(gradient,at:0) 最佳答案 让CAShap