• 1
name Punditsdkoslkdosdkoskdo

Display UIViewController as Popup in iPhone

Since there is no complete, definitive answer to this common recurring question, I'll ask and answer it here.

Often we need to present a UIViewController such that it doesn't cover full screen, as in the picture below.

enter image description here

Apple provides several similar UIViewController, such as UIAlertView, Twitter or Facebook share view controller, etc..

How can we achieve this effect for a custom controller?


You can do this in Interface Builder.

  • For the view you wish to present modally set its outermost view background to transparent
  • Control + click and drag from the host view controller to the modal view controller
  • Select present modally
  • Click on the newly created segue and in the Attribute Inspector (on the right) set "Presentation" to "Over Current Context"
  • 0
Reply Report