Animation Performance

for button in buttonGroup {
    UIView.animateWithDuration(1, animations: {
        button.alpha = 0
    })
}

VS

UIView.animateWithDuration(1, animations: {
        for button in buttonGroup {
            button.alpha = 0
        }
    })

I have more than 40 buttons in buttonGroup, maybe later, I wonder which way is better? The standard is resource consumption.

+4
source share
3 answers

Obviously the second. Because in the case of the first one it UIView.animateWithDurationis called a lot (the common button in buttonGroup) times. This is not effective programming, but the animation becomes volatile. But in the case of the second, he UIView.animateWithDurationcalled only once and performed the same result.

0
source

xcodes unit test . unit test, .

? , , UIView , UIButtons.

+1

. xCode debug navigator (: cmd + 6), , . , , . . ( )

0

All Articles