CAShapeLayer лучший способ изменить на вращение - PullRequest
0 голосов
/ 22 января 2019

Я создал цветной CAShapeLayer

    backgroundFillLayer.path = UIBezierPath(rect: foregroundColourView.bounds).cgPath
    backgroundFillLayer.fillColor = backgroundColours[pendingIndex].cgColor
    backgroundFillLayer.opacity = 1
    foregroundColourView.layer.addSublayer(backgroundFillLayer)

Который не вращался при изменении ориентации. Я попытался добавить следующее в viewDidLayoutSubviews , и они не работали

foregroundFillLayer.frame = self.view.bounds
foregroundFillLayer.needsDisplayOnBoundsChange = true (when created)

и случилось на

foregroundFillLayer.path = UIBezierPath(rect: foregroundColourView.bounds).cgPath

Но здесь, конечно, я воссоздаю путь? Разве это не тяжеловес, и есть гораздо лучший способ сделать это, чего я не знаю f

...