Original: Https://github.com/50pixels/FPPopover
The framework can be used to replace Apple's Uipovercontroller, because it not only supports the IPAD, it also supports the iPhone. In addition, you can customize its look and style in the IPhone.
This project was originally an open source component on Mobiloud, and after I realized its value, I decided to follow up on the project. You are welcome to leave a message or share your code via pull request.
Function
- Similar to Uipopovercontroller.
- Support both IPhone and IPad.
- Do not use any pictures, write them completely in Quartz.
- Customizable look (color, size).
- Automatically adjusts the pop-up direction (arrow direction). It will automatically find the best direction and size in any case.
- You can not display arrows.
- You can not display borders.
- Use of the MIT License Agreement (can be used for commercial purposes, can be modified and republished)
- Support ARC (see here ).
Prepare before use
To use Fppopovercontroler, you need the following files:
- FPPOPOVERCONTROLLER.M and. h (Controller)
- FPPOPOVERVIEW.M and. h
- FPTOUCHVIEW.M and. M
- ARCMacros.h
Usage
Simple example:
-(Ibaction) buttonclicked: (uibutton*) OKButton {
The view controller youwant to present as PopOver
Yourviewcontroller*controller = [[Yourviewcontroller alloc] init];
Our PopOver
Fppopovercontroller*popover = [[Fppopovercontroller alloc] initwithviewcontroller:controller];
The PopOver'll bepresented from the OKButton view
[Popoverpresentpopoverfromview:okbutton];
No release (ARC enable)
[Controller release];
}
The above code will show a black popover, the direction of the arrows will be adjusted automatically, the content size is 200*300, and the delegate is not used.
The title of the Yourviewcontroller object will be the title of the PopOver.
Specify size
The default content size is 200x300. But you can set it up:
Popover.contentsize = Cgsizemake (150,200);
The Content property specifies the maximum size, and the actual displayed size is optimized based on the screen layout (for example, depending on the horizontal or vertical screen mode).
Specify color
- Fppopoverblacktint (default)
- Fppopoverlightgraytint
- Fppopovergreentint
- Fppopoverredtint
Popover.tint = Fppopoverredtint;
If you need more color please contact me.
Force Specify Arrow Direction
The Arrowdirection property can force a specified arrow direction:
Popover.arrowdirection = Fppopoverarrowdirectionup;
Do not show arrows
Do not show arrows using code:
Popover.arrowdirection = Fppopovernoarrow;
Do not show title
The view controller you wantto present as PopOver
Yourviewcontroller *controller= [[Yourviewcontroller alloc] init];
Controller.title = nil;
Do not display borders
Popover.border = NO;
Popover.tint = Fppopoverwhitetint;
Transparent
To change the transparency through the Alpha property:
Popover.alpha = 0.8;
Delegate message
First set the delegate property:
Yourviewcontroller *controller= [[Yourviewcontroller alloc] init];
Fppopovercontroller *popover =[[fppopovercontroller alloc] Initwithviewcontroller:controller];
Popover.delegate = Controller;
....
When PopOver is displayed
-(void) Presentednewpopovercontroller: (fppopovercontroller*) Newpopovercontroller shoulddismissvisiblepopover: (FP popovercontroller*) Visiblepopovercontroller;
This method is called when there is a new popover rendering. If you want to dissolve the old PopOver (release), send the dismiss message in this method.
-(void) Presentednewpopovercontroller: (fppopovercontroller*) Newpopovercontroller shoulddismissvisiblepopover: (FP popovercontroller*) visiblepopovercontroller{
[Visiblepopovercontrollerdismisspopoveranimated:yes];
[Visiblepopovercontrollerautorelease];
}
When PopOver dissolved,
-(void) Popovercontrollerdiddismisspopover: (fppopovercontroller*) Popovercontroller;
This method is called when PopOver is disbanded. This occurs when the user clicks outside of PopOver or sends a DIMISS message.
"iOS Open Source Code" (4): Fppopover