{
private var activityIndicator: CAShapeLayer!
override init(frame: CGRect) {
super.init(frame: frame)
setupLoaderView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupLoaderView()
}
private func setupLoaderView() {
self.backgroundColor = UIColor.black.withAlphaComponent(0.2)
let circlePath = UIBezierPath(
arcCenter: CGPoint(x: frame.size.width / 2, y: frame.size.height / 2),
radius: 16,
startAngle: -CGFloat.pi / 2,
endAngle: 2 * CGFloat.pi - CGFloat.pi / 2,
clockwise: true
)
activityIndicator = CAShapeLayer()
activityIndicator.path = circlePath.cgPath
activityIndicator.fillColor = UIColor.clear.cgColor
activityIndicator.lineWidth = 2.0
let gradientLayer = CAGradientLayer()
gradientLayer.frame = bounds
gradientLayer.colors = [
UIColor(hexColor: "#FFFFFF").cgColor,
UIColor(hexColor: "#0d0b0b").cgColor
]
gradientLayer.startPoint = CGPoint(x: 0.0, y: 0.5)
gradientLayer.endPoint = CGPoint(x: 1.0, y: 0.5)
activityIndicator.strokeColor = UIColor(hexColor: "#FFFFFF").cgColor
activityIndicator.mask = gradientLayer
let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotationAnimation.byValue = 2 * CGFloat.pi
rotationAnimation.duration = 1.0
rotationAnimation.repeatCount = .infinity
activityIndicator.add(rotationAnimation, forKey: "rotation")
layer.addSublayer(activityIndicator)
}
func show() {
self.isHidden = false
}
func hide() {
self.isHidden = true
}
}
видимо из-за этой строки: activityIndicator.mask = gradientLayer
А что мне сделать? :( я и так фигачила и так все равно не работает
Обсуждают сегодня