ios - Unable to Get UIButton to Fade In on ViewDidLoad -


as stated in title, unable uibutton fade in on viewdidload method. here code far:

viewcontroller.swift

import uikit import quartzcore class viewcontroller: uiviewcontroller {      @iboutlet weak var nextbutton: uibutton!      override func viewdidload() {         super.viewdidload()          self.nextbutton.fadein(duration: 10.0, delay: 10.0)     } } 

uiviewextensions.swift

import foundation import uikit  extension uiview {     func fadein(duration: nstimeinterval = 1.0, delay: nstimeinterval = 0.0, completion: ((bool) -> void) = {(finished: bool) -> void in}) {         uiview.animatewithduration(duration, delay: delay, options: uiviewanimationoptions.curveeasein, animations: {             self.alpha = 1.0             }, completion: completion)  }      func fadeout(duration: nstimeinterval = 1.0, delay: nstimeinterval = 0.0, completion: (bool) -> void = {(finished: bool) -> void in}) {         uiview.animatewithduration(duration, delay: delay, options: uiviewanimationoptions.curveeasein, animations: {             self.alpha = 0.0             }, completion: completion)     } } 

you not want start animations fade in, on viewdidload. method called when class finished initializing (right after init). happens before view visible. want start animations in viewdidappear. called once view visible on screen. when start in viewdidload, it's done animation time gets viewdidappear, assuming of course did fade in on .5 second.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -