ios - Present modal view controller in half size -


i tried implement presenting modal view controller on other uiviewcontroller sized half parent view controller as:

class viewcontroller: uiviewcontroller, uiviewcontrollertransitioningdelegate {      override func viewdidload() {         super.viewdidload()     }      @ibaction func tap(sender: anyobject) {         var storyboard = uistoryboard(name: "main", bundle: nil)         var pvc = storyboard.instantiateviewcontrollerwithidentifier("customtableviewcontroller") uitableviewcontroller          pvc.modalpresentationstyle = uimodalpresentationstyle.custom         pvc.transitioningdelegate = self         pvc.view.backgroundcolor = uicolor.redcolor()          self.presentviewcontroller(pvc, animated: true, completion: nil)     }      override func didreceivememorywarning() {         super.didreceivememorywarning()     }      func presentationcontrollerforpresentedviewcontroller(presented: uiviewcontroller, presentingviewcontroller presenting: uiviewcontroller, sourceviewcontroller source: uiviewcontroller) -> uipresentationcontroller? {         return halfsizepresentationcontroller(presentedviewcontroller: presented, presentingviewcontroller: presenting)     } }  class halfsizepresentationcontroller : uipresentationcontroller {     override func frameofpresentedviewincontainerview() -> cgrect {         return cgrect(x: 0, y: 0, width: containerview.bounds.width, height: containerview.bounds.height/2)     } } 

now need dismiss half sized view controller when user click parent view controller.
how achieve this?

you need add uiview halfsizepresentationcontroller (maybe dimming view). add tap gesture recognizer view handle tap event called dismiss presenting view:

func dimmingviewtapped(taprecognizer: uitapgesturerecognizer) {         presentingviewcontroller.dismissviewcontrolleranimated(true, completion: nil)     } 

maybe help: http://zappdesigntemplates.com/custom-presentations-using-uipresentationcontroller-swift/


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -