Perfom an action in viewDidAppear only when view is first displayed
<p>I have an app that has a view that contains 4 circles made with UIBezierPath.</p>

<p><a href="https://i.stack.imgur.com/CTnL2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CTnL2.png" alt="view with circles"></a></p>

<p>And you can click on a certain circle to get details about one of the items</p>

<p><a href="https://i.stack.imgur.com/WTRqJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WTRqJ.png" alt="view with details"></a></p>

<p>The thing is, Circles are in subviews that have some constraints, so I could not draw them in the viewDidLoad method (I tried but it was a mess) so the whole drawing thing is done in the viewDidAppear method but that makes the circles to be drawn each time the view appear.</p>

<p>So if I click on a circle then come back to the circles view a lot of time I end up with :</p>

<p><a href="https://i.stack.imgur.com/ikytp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ikytp.png" alt="view with circles after I went to check the details a lot for any circle"></a></p>

<p>I also tried to use the viewDidLayoutSubviews method but I get an infinite loop. So I'm asking if anyone has an idea to deal with that. (with the cleanest way possible)</p>

<p>This is what my viewDidAppear looks like :</p>

<pre><code>override func viewDidAppear(animated: Bool) {
        createCircle(firstCircle, text: "Breathe", color: blue, directionForAdjustment: 1, identifier: 0)
        createCircle(secondCircle, text: "Cocoon", color: green, directionForAdjustment: 1, identifier: 1)
        createCircle(thirdCircle, text: "Smokeless", color: cyan, directionForAdjustment: -1, identifier: 2)
        createCircle(fourthCircle, text: "Sleep", color: purple, directionForAdjustment: -1, identifier: 3)
}
</code></pre>