uitableview - BackgroundImageView should Animate -
i want fade in uiimageview backgroundview of uitableview. it's not animating. image there. ideas why?
here code:
override func viewwillappear(animated: bool) { super.viewwillappear(animated) let backgroundimage = uiimage(named: "theimage") let imageview = uiimageview() imageview.image = backgroundimage imageview.contentmode = uiviewcontentmode.scaleaspectfit self.tableview.backgroundview = imageview //tried way imageview.alpha = 0.0 //and way self.tableview.backgroundview?.alpha = 0.0 uiview.animatewithduration(3.0, animations: { () -> void in //both not animating self.tableview.backgroundview?.alpha = 1.0 imageview.alpha = 1.0 }) } thanks
it doesn't work because call in viewwillappear happens before view loaded animation invisible. try change viewdidappear , work. don't need change
self.tableview.backgroundview?.alpha = 0.0 imageview.alpha enough, try that:
override func viewdidappear(animated: bool) { super.viewdidappear(animated) let backgroundimage = uiimage(named: "theimage") let imageview = uiimageview() imageview.image = backgroundimage imageview.contentmode = uiviewcontentmode.scaleaspectfit self.tableview.backgroundview = imageview imageview.alpha = 0.0 uiview.animatewithduration(3.0, animations: { () -> void in imageview.alpha = 1.0 }) }
Comments
Post a Comment