简体   繁体   中英

How to make Popup via storyboard(xib?) and programmatically Xamarin.iOS

For some reason i want to know how exactly i can implement Popup in Xamarin.iOS via storyboard and programmatically .


At current moment, i'm doing pretty simple workaround:

Inside designer, i'm dropping additional view(as popup) and configure like that
MyPopupView.Hidden = true;

After some steps(nvm), i'm showing this popup via

MyPopupView.Hidden = false;

And the result is :
在此处输入图片说明

Yeah, that is bad and very poor approach, because what if need these 5 guys or more ?
I will not be able to design my ViewController , because it will be stuffed with these views.
Also, for some reason i want to show arrow (see img below) and shadow (outside of popup) for better usability.


That what is exactly i want to do :
在此处输入图片说明

or this one(but inside, i want to put for eg my xib or VC,where i can drop some other views, like .gif animation):
在此处输入图片说明

or this one:
在此处输入图片说明

and finally, what i want(this one is amazing) :
在此处输入图片说明


Main idea to use storyboard(to make life easy with working on constraints and autolayout),but maybe it can be done programmatically the same.

I think that is possible to do that with UIAlertController , just needs to insert our View , but dunno is that right approach.

Thanks for any advice.

The last two images you posted can be accomplished using storyboards.

Essentially what you to do is create a separate scene/view controller in your storyboard and set it's presentation property to "over current context" . 在此处输入图片说明 在此处输入图片说明

Alternatively you can set the segue to "Show modally" and the presentation property of the segue to "over current context" in Xcode

在此处输入图片说明

(for some reason the "Over current context" option doesn't come up in Xamarin Studio (at least not in Xamarin Studio 6) and when you open it back up in XS it will display a "Error while creating this entry" message by the presentation property but it should still work).

The next step is to set the root view to be transparent (background color = clear color ) and then have a child view with your content.

在此处输入图片说明

If you want the semi-transparent overlay affect then what you can do is have two "sibling" child views one with your content (same as before) and a second view which is constrained to the edges of the root view and has it's alpha property set to something less then 1.

在此处输入图片说明

在此处输入图片说明

And here's the result...

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM