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
selected view should circular. when print constain's values gives height , width 214 only
- i think might fetching value in
viewwillappear
orviewdidload
views frames don't updated when these method gets called - so need fetch width or height in
viewdidappear
method. - 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
Post a Comment