iOS) UIImageView UITapGestureRecognizer 로 액션설정하기

less than 1 minute read

UIImageView UITapGestureRecognizer 로 액션설정하기

// MARK: - @IBOutlet Properties
@IBOutlet var loginImageView: UIImageView!

//...

// MARK: - Methods
func loginTapAction() {
    let login = UITapGestureRecognizer(target: self, action: #selector(login))
    loginImageView.isUserInteractionEnabled = true
    loginImageView.addGestureRecognizer(login)
}

// MARK: - @objc Methods
@objc
func login() {
    guard let nextVC = UIStoryboard(name: Const.Storyboard.Name.FirstOnboarding, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Name.FirstOnboarding) as? FirstOnboardingVC else {
        return
    }
    
    self.navigationController?.pushViewController(nextVC, animated: true)
}

Categories:

Updated: