swift - frame issue in UINavigationController class when rotating -
i've used custom uinavigationcontroller class put colour gradient across navbar. custom navclass determines frame size of navbar, puts gradient inside. problem is, when rotate portrait landscape, gradient fills portrait portion of landscape bar. i've assigned custom uinavigationcontroller class navigation view in storyboard.
so i'm guessing somehow need call refresh frame size in custom navclass when rotation done, i'm not sure how or where?
here's relevant code snippet, override func viewdidload() of custom navclass.
let gradientlayer = cagradientlayer() gradientlayer.frame = self.navigationbar.bounds self.navigationbar.layer.insersublayer(gradientlayer, atindex: 1)
i tried putting inside viewwillappear(), didn't work. help?
viewdidload()
, viewwillappear()
don't called on rotation, code won't update frame there.
you should add gradientlayer.frame = self.navigationbar.bounds
viewwilllayoutsubviews()
leave other code in viewdidload()
don't wind multiple gradient layers.
Comments
Post a Comment