ios - my view looks different on iphone 5 and iphone 6 even though it has constraints - what is wrong here? -


in swift app applying gradient view. following code:

@iboutlet weak var gradientview: uiview!  override func viewdidload(){     super.viewdidload()      let layer = cagradientlayer()     layer.frame = cgrect(x: 0, y: 0, width: self.gradientview.frame.width, height: self.gradientview.frame.height)     layer.colors = [uicolor.clear.cgcolor, uicolor.white.cgcolor]     gradientview.layer.addsublayer(layer) } 

in storyboard gradientview black 1 here:

enter image description here

its constraints are:

enter image description here

so touches edges on each side, top , white panel on bottom.

when run in iphone5 simulator have:

enter image description here

and that's fine. when run on iphone 6s, see:

enter image description here

what's problem here, since constraints applied?

the problem gradientview's frame not updated yet in viewdidload. try instead:

let gradientlayer = cagradientlayer()   override func viewdidload(){     super.viewdidload()        gradientlayer.colors = [uicolor.clear.cgcolor, uicolor.white.cgcolor]     gradientview.layer.addsublayer(gradientlayer) }  override func viewdidlayoutsubviews(){     super.viewdidlayoutsubviews()     gradientlayer.frame = gradientview.bounds } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -