If I'm using
UIView.animate
for 28 UIViewImages where them alpha changed from alpha = 0 to alpha = 0.5. Simulator loads my Macbook CPU upto 200%, but simulator in XCode debug navigator showing just 0-4% CPU load. If I run the app on iPhone X
, all the same. iPhone CPU is 0-4%, but temperature of the device is high. If I'm comment animation function, app working good and iPhone have normal temperature. Is this a normal situation with simultaneous animation of 28 view? Or should it not be so?
Function for add View
func addView() {
for _ in 0...27 {
imageViews.append(UIImageView(image: UIImage(named: "logo_main")))
}
imageViews.forEach{ (view) in
view.contentMode = .scaleAspectFill
view.center = CGPoint(x: bounds.midX, y: bounds.maxY + view.bounds.size.height)
addSubview(view)
}
layoutIfNeeded()
}
Animate Background Function
func animateBackground() {
self.imageViews.forEach { view in
view.alpha = 0
let rand = TimeInterval(self.imageViews.count.arc4random)
UIView.animate(withDuration: 3,
delay: rand,
options: [.repeat, .autoreverse, .curveEaseInOut],
animations: { view.alpha = 0,5 },
completion: nil)
}
}
It's normal behavior of app? Maybe there is another way to make animated background blinking?