Swift - How to automatically change Imageview image

Asked

Viewed 856 times

1

I have some images and an Imageview according to the photos

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

I would like to be able to switch the image of View, switching from one to the other every 5 seconds automatically.

How could I do this?

2 answers

1


  • Very interesting, thanks for the tip, but is there any way I could keep it going? As a slide even, I enter the app and the home screen appears the slide interleaving between the 3 images.

  • @Cristiancotrena I only updated the answer

  • I wanted to do it exactly the way you did, but with images from the Internet. I take an image, stored in an Uiimage, when I try to place the Uiimage in the Animate (where it is informing the images), error.

  • I might be doing it wrong too, but if you mail me, I can show you how I tried to do it

  • Hello friend, I managed to do the way I wanted. But I have a doubt, when I want to go to another Viewcontroller how do I stop the animation?

1

Just now put the logic to change for each image.

NSTimer(timeInterval: 0.5, target: self, selector: "TrocarImagem", userInfo: nil, repeats: true)

func TrocarImagem() {
    let imagem = UIImage(named:"imagem01.jpg")
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.