I had a similar problem with UIRefreshControl, which did not display color correctly when loading the view, and I call beginRefreshing (). If the user pulls for an update, the control correctly displays the tintColor I specified.
First, a subclass of update management. Then override the didMoveToWindow method in the subclass. The following code finds an animated element to create a counter and sets its background color.
This code uses the UIView extension to return all subviews of the view (I used John Willis' answer from Swift: iterate over all subviews recursively to find a specific class and add to the array ).
class CustomRefreshControl: UIRefreshControl { override func didMoveToWindow() { super.didMoveToWindow() if let l = getNestedSubviews().first(where: { $0.layer is CAReplicatorLayer }), l.subviews.count > 0 { l.subviews[0].backgroundColor = UIColor.orange
The spinner has a CAReplicatorLayer, the view of which contains one subview. This subview is just a rectangle that implements a graphic element for a counter. This is the graphic element that you are coloring.
source share