iOS: Set setImageInputs of image slideshow to array of images

前端 未结 2 1672
挽巷
挽巷 2021-01-25 20:26

I\'m using an image slideshow from here:

    iconArr = [UIImage(named: \"home-min\")!,UIImage(named: \"category-
   min\")!,UIImage(named: \"settings-min\")!,UI         


        
2条回答
  •  南笙
    南笙 (楼主)
    2021-01-25 21:10

    you should try this way for sure, because you reset inputs in your for-loop

    var imageSource: [ImageSource] = []
    for image in self.iconArr {
        let img = image
        imageSource.append(ImageSource(image:  img))
    }
    self.SlideShow.setImageInputs(imageSource)
    

    As sooper stated, can be done this way

    let imageSources = self.iconArr.map { ImageSource(image: $0) } 
    

提交回复
热议问题