ios - Slide menu - move from right to left and back -


i have slide menu when click on screen menu comes out right left. how can write code if click button move left right?

my slide menu:

enter image description here

my code:

private void updatetableviewposition(cgpoint positon)     {         // set position of button based on provided argument         _buttontogglevisibility.frame = new coregraphics.cgrect(positon.x , _buttontogglevisibility.frame.y, _buttontogglevisibility.frame.width, _buttontogglevisibility.frame.height);          // todo:         // if button outside of screen         //     move screen          // move tableview right aligned of button         _tableview.frame = new coregraphics.cgrect(_buttontogglevisibility.frame.right, _tableview.frame.y, _tableview.frame.width, _tableview.frame.height);     }      public override void touchesended(nsset touches, uievent evt)     {         base.touchesended(touches, evt);          uitouch touch = (uitouch)touches.anyobject;          _moving = false;          // todo: fix button clickable         // if touch clicked button         //     open (or close) view following animation code         uiview.animate(0.9f, () =>         {             // todo: animation code incorrect. moves view 100px relatively              // current position, should rather either set button left corner or right              // corner @ fixed positions             updatetableviewposition(new cgpoint(_buttontogglevisibility.frame.x - _buttontogglevisibility.frame.left, 0));          }, null);     }      public override void touchescancelled(nsset touches, uievent evt)     {         base.touchescancelled(touches, evt);          _moving = false;     }      public override void touchesbegan(foundation.nsset touches, uievent evt)     {         base.touchesbegan(touches, evt);          uitouch touch = (uitouch)touches.anyobject;          coregraphics.cgpoint pos = touch.locationinview(this);           if (pos.x > _buttontogglevisibility.frame.x && pos.x < _buttontogglevisibility.frame.right && pos.y > _buttontogglevisibility.frame.y && pos.y < _buttontogglevisibility.frame.bottom)         {             // did click on view             _moving = true;         }          _buttontogglevisibility.touchupinside += (sender, e) =>        {         };     } } 

i use autolayout , uiview animation move view of controls , down. (think keyboard more flexibility.) board has "done" button, animatedly moves board (and it's subviews) out of view.

since have array of boards, there's code here addressing tag property. that's find board work with.

the key things to:

  • (1) change heightanchor (or in case widthanchor)
  • (2) animate call superview's layoutifneeded

..

private var boardin:[nslayoutconstraint] = [] private var boardout:[nslayoutconstraint] = [] private var tabboards:[tabboard] = []  public func createcontrolboard(     _ tag:int     )  -> controlboard {     let newboard = controlboard(tag)     boardout.append(newboard.heightanchor.constraint(equaltoconstant: 100))     boardin.append(newboard.heightanchor.constraint(equaltoconstant: 0))     newboard.donebutton.addtarget(self, action: #selector(hidetabboard), for: .touchupinside)     tabboards.append(newboard)     return newboard }  public func showtabboard(_ tag:int) {     in 0...tabboards.count-1 {         nslayoutconstraint.deactivate([boardout[i]])         nslayoutconstraint.activate([boardin[i]])         tabboards[i].makecontrolshidden(true)     }     nslayoutconstraint.deactivate([boardin[tag-1]])     nslayoutconstraint.activate([boardout[tag-1]])     tabboards[tag-1].makecontrolshidden(false)     uiview.animate(withduration: 0.3) { self.superview?.layoutifneeded() } }  public func hidetabboard(_ tag:int) {     nslayoutconstraint.deactivate([boardout[tag-1]])     nslayoutconstraint.activate([boardin[tag-1]])     tabboards[tag-1].makecontrolshidden(true)     uiview.animate(withduration: 0.3) { self.superview?.layoutifneeded() } } 

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 -