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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -