objective c - NSLayoutConstraint.constraintsWithVisualFormat align bottom right -
i want put indicator view in bottom right of container view, have code insert view
var img:uiimageview? img = uiimageview(frame: cgrect(x: 0, y: 0, width: singlecheckviewwidth, height: singlecheckviewheight)) img!.image = uiimage(named: "check") img!.tag = 21 img!.translatesautoresizingmaskintoconstraints = false img!.backgroundcolor = uicolor.redcolor() //aggiungo la vista al fumetto cell.textview!.addsubview(omg!)
the problem code have icon in top left 10px margin , works fine:
let iconverticalconstraints = nslayoutconstraint.constraintswithvisualformat( "v:|-10-[indicator(\(singlecheckviewheight))]", options: [], metrics: nil, views: views) allconstraints += iconverticalconstraints let horizontalconstraints = nslayoutconstraint.constraintswithvisualformat( "h:|-10-[indicator(\(singlecheckviewwidth))]", options: [], metrics: nil, views: views) allconstraints += horizontalconstraints
here image:
but if try move image in bottom left code:
let iconverticalconstraints = nslayoutconstraint.constraintswithvisualformat( "v:[indicator(\(singlecheckviewheight))]-10-|", options: [], metrics: nil, views: views) allconstraints += iconverticalconstraints let horizontalconstraints = nslayoutconstraint.constraintswithvisualformat( "h:[indicator(\(singlecheckviewwidth))]-10-|", options: [], metrics: nil, views: views) allconstraints += horizontalconstraints
i don't see image anymore, if try put image in top left code:
let iconverticalconstraints = nslayoutconstraint.constraintswithvisualformat( "v:|-10-[indicator(\(singlecheckviewheight))]", options: [], metrics: nil, views: views) allconstraints += iconverticalconstraints let horizontalconstraints = nslayoutconstraint.constraintswithvisualformat( "h:[indicator(\(singlecheckviewwidth))]-10-|", options: [], metrics: nil, views: views) allconstraints += horizontalconstraints
i obtain image outside container, image below:
any ideas what's wrong? , how can move icon in bottom right angle?
thanks!
if of parent views haven't been aligned properly, nor siblings, things go awry. on top of that,
cell.textview!.addsubview(omg!)
omg
? assume meant img
? or wrong?
also, on top of this, there's no mention kind of container you're placing in?
if it's nsview or uiview, xyz.cell isn't place put it. if tableiewview, cell be, constraints set up. if ios, uitableviewcell, topmost view "of cell" i.e., did add background view image view overshadowing it?
could elaborate little scenario can better picture? (no pun intended)
Comments
Post a Comment