SHARE
TWEET

Untitled

a guest Jun 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var imagesArray = [String]()
  2. var passDataDelegate: PassImageName?
  3.  
  4. @IBOutlet weak var slider : CPImageSlider!
  5.  
  6. @IBOutlet weak var autoSwitch : UISwitch!
  7. @IBOutlet weak var arrowSwitch : UISwitch!
  8. @IBOutlet weak var indicatorSwitch : UISwitch!
  9. @IBOutlet weak var sliderSwitch : UISwitch!
  10. @IBOutlet weak var circularSwitch : UISwitch!
  11.  
  12. override func viewDidLoad() {
  13.     super.viewDidLoad()
  14.  
  15.     imagesArray = ["wallpaper1.jpg","wallpaper2.jpg","wallpaper3.jpg","wallpaper4.jpg"]
  16.     slider.images = imagesArray
  17.     slider.delegate = self
  18.     let zoom : CGFloat = 0.8
  19.     autoSwitch.transform = CGAffineTransform(scaleX: zoom, y: zoom)
  20.     arrowSwitch.transform = CGAffineTransform(scaleX: zoom, y: zoom)
  21.     indicatorSwitch.transform = CGAffineTransform(scaleX: zoom, y: zoom)
  22.     sliderSwitch.transform = CGAffineTransform(scaleX: zoom, y: zoom)
  23.     circularSwitch.transform = CGAffineTransform(scaleX: zoom, y: zoom)
  24.  
  25.     autoSwitch.isOn = slider.autoSrcollEnabled
  26.     arrowSwitch.isOn = slider.enableArrowIndicator
  27.     indicatorSwitch.isOn = slider.enablePageIndicator
  28.     sliderSwitch.isOn = slider.enableSwipe
  29.     circularSwitch.isOn = slider.allowCircular
  30. }
  31.  
  32. func sliderImageTapped(slider: CPImageSlider, imageName: String, index: Int) {
  33.  
  34.     passDataDelegate?.passData(clickedImageName: imageName)
  35.  
  36.     guard let destinationVC = storyboard?.instantiateViewController(withIdentifier: "ImageViewController") as? ImageViewController else {
  37.         return
  38.     }
  39.  
  40.     present(destinationVC, animated: true, completion: nil )
  41.  
  42.     print("(index)")
  43. }
  44.      
  45. @IBOutlet weak var image: UIImageView!
  46.  
  47. var imageName:String?
  48.  
  49. func passData(clickedImageName: String) {
  50.      imageName = clickedImageName
  51. }
  52.  
  53. override func viewDidLoad() {
  54.     super.viewDidLoad()
  55.     image.image = UIImage(named: imageName ?? "wallpaper1.jpg")
  56. }
  57.  
  58. @IBAction func dismiss(_ sender: UIButton) {
  59.     dismiss(animated: true, completion: nil)
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top