ios - get Height Value from NSLayoutConstraint -


in project using autolayout, there 1 uiview subview main view, have set width(using constrains) equal 2 :3 superview's width , height equal view. need view circular shape setting cornerradius heightofview/2. there 1:1 aspect ration of views's height , width. have created outlet of constrain

 @iboutlet weak var circleheight: nslayoutconstraint 

now want acces height or width m not gwtting actual value,

circleheight.firstitem.frame.width 

i getting value have stored storyboard, there missing not figured out

enter image description here selected view should circular. when print constain's values gives height , width 214 only

  1. i think might fetching value in viewwillappear or viewdidload views frames don't updated when these method gets called
  2. so need fetch width or height in viewdidappear method.
  3. if height or width in viewdidlayoutsubviews, performance gets degraded gets called many times.

here code

override func viewdidappear(animated: bool){        super.viewdidappear(animated)        let viewheight = cgrectgetheight(yourview.frame)        yourview.layer.cornerradius = viewheight / 2        yourview.layer.maskstobounds = true     } 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -