This is an example to create a Pop Up UIView (Swift 2.3)
Create a new view file (.xib), this is the PopUp View.
Import the popUpViewController.swift from this repo into your project
Assign the popUpView to your popUpView Controller:
- in the .xib file select the File's Owner (from righte side). then, in Custom Class of Identity Inspector tab, write popUpViewController.
- then from Outlets in Connection Inspector, Connect
viewto UIView of your .xib file
Now, you should make and instance of controller and handle the popUp after click or sth
- In your main ViewController (that controller you want to show popUpUIView), create an Instance of Controller:
let popUpController = popUpViewController()- Then in delcare the Instance in viewDidLoad:
popUpController.crateInstanceOfPopUp(self.view, theViewController: self, sizeOfPopUpViewContainer: SIZE_OF_POPUPVIEW_CONTAINER)- and for the last step, call the
openPopUpViewevery where you want to do that (like after a button click):
popUpController.openPopUpView()- You must know, whenever you call
openPopUpView()it detect popUp situation (like it is open or closed), so you dont need to delcare and handle it, it's automated - You can add everything in your popUpView and use it in controller, like a UIButton I used in this example
When you're making an instance of popUpUIView you can define two additional attributes:
needMoreGesture: by default this attribute isfalse. means, there is no More Section. if you want more section you should set this attribiute totrue. Then you can add more UI Elemnt in your UIView 'under the main popUpView.
popUpController.crateInstanceOfPopUp(self.view, theViewController: self, sizeOfPopUpViewContainer: 200, needMoreGesture: true)backgroundColor: by default this attrbiute isDarkGray. If you want change the background color just set your favorite color az an attribute.
popUpController.crateInstanceOfPopUp(self.view, theViewController: self, sizeOfPopUpViewContainer: 200, backgroundColor: UIColor.redColor())- As you know you can set all attribiutes once at all :D :
popUpController.crateInstanceOfPopUp(self.view, theViewController: self, sizeOfPopUpViewContainer: 200, needMoreGesture: true, backgroundColor: UIColor.redColor())
