简体   繁体   中英

Call extension function IOS Swift

How can I call extension function, so that the button is encouraged to call the view. I made a UiButton Extension with a function to animate a button, and everything works, but only if I call it from:

@IBAction func botonVuelta(_ sender: UIButton) {
    sender.pulsarAnimacion()
}

but if you called it from viewDidLoad it doesn't work:

override func viewDidLoad() {
    super.viewDidLoad()
    botones.layer.cornerRadius = 20
    botones.pulsarAnimacion()
}

I'd appreciate it if you could give me a solution, I thank you in advance

viewDidLoad is a very early place to animate a view , try inside

override func viewDidAppear(_ animated:bool) {
     super.viewDidAppear(animated)
     botones.pulsarAnimacion()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM