HOW TO ANIMATE UIVIEW WITH A FOR LOOP : I'm a bit new to swift and iOS programming. I would like to move a rectangle within a for loop to  create a random walk. But I only get the end position not motion in between. What do I have to do to see the individual steps?


    import UIKit
    import PlaygroundSupport
    
    class ViewController:UIViewController{
        override func viewDidLoad() {
            super.viewDidLoad()
        }
    }
    
    class bird: UIView {
        var x:CGFloat
        var y:CGFloat
        
        override init(frame: CGRect){
            self.x=0
            self.y=0
            super.init(frame: frame)
        }
        
        func stepit(dx: CGFloat, dy: CGFloat ){
            self.frame.origin.x += dx
            self.frame.origin.y += dy
        }
        
        override func draw(_ rect: CGRect) {
            self.backgroundColor = #colorLiteral(red: 0.960784316062927, green: 0.705882370471954, blue: 0.200000002980232, alpha: 1.0)
        }
        
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }
    }
    
    let viewController = ViewController()
    PlaygroundPage.current.liveView = viewController
    PlaygroundPage.current.needsIndefiniteExecution = true
    
    let b=bird(frame: CGRect(x: 0, y: 0, width: 20, height: 20))
    viewController.view.addSubview(b)
    
    for i in i... 100 {
       b.stepit(dx: CGFloat(arc4random_uniform(10)), dy: CGFloat(arc4random_uniform(10) ))
    }