I have called this function after it is declared and everything works but the UIImageViews don\'t change their image. I would be very grateful for your help.
I think that the problem is the sleep(3), this line block the main thread. Instead of that use:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
// your code here
}
Apple Reference
Note:
For the most part, use UIKit classes only from your app’s main thread. This is particularly true for classes derived from UIResponder or that involve manipulating your app’s user interface in any way.
Regards
Not sure where you are updating your image either in main thread or background. Don't use sleep, Instead try updating your image in main thread asynchronously with delay.
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3))
{ self.GreenImage.image = UIImage }