0

I am working on an application where the user clicks to add a station, from there a pop-up window will appear asking the user for the appropriate information, the UIView will be animated but I am having trouble getting it to work from insides its separate file.

Here is the code from the Animations.swift file.

import Foundation
import UIKit

class Animations: UIView {

    func animatePopUpIn(view: UIView, controller: UIViewController) {

        controller.view.addSubview(view)
        view.center = center

        view.transform = CGAffineTransform.init(scaleX: 1.3, y: 1.3)
        view.alpha = 0

        UIView.animate(withDuration: 0.4) {
            controller.view.alpha = 1
            controller.view.transform = CGAffineTransform.identity
        }

    }

}

Here is the code for the StationController.swift file.

import UIKit

class StationController: UIViewController {

    @IBOutlet var addStationView: UIView!
    var animation = Animations()


    override func viewDidLoad() {
        super.viewDidLoad()

        navigationItem.title = "Stations"
    }

    @IBAction func addStationTapped(_ sender: Any) {

        animation.animatePopUpIn(view: addStationView, controller: self)
        print("Displayed Pop Up")
    }


    @IBAction func dismissPopUpTapped(_ sender: Any) {


    }


}

For some reason upon tapping addStationTapped nothing appears, any help would be great for I am fairly new to working with classes in this manner. Thanks in advance.

mhillsman
  • 770
  • 1
  • 8
  • 26
Chandler Long
  • 77
  • 2
  • 11

1 Answers1

0

One more better way is to do this is by making seperate viewcontroller and add it as popover . you can use third party class or manually add view controller as pop . if you want to add it manually then i can help.

Jitendra Tanwar
  • 249
  • 2
  • 11