# Import <uikit/uikit. h>
@ Interface dpoverview: uiview
+ (Void) showpoveratpoint :( cgpoint) Point inview :( uiview *) view withcontentview :( uiview *) cview;
-(Void) showpoveratpoint :( cgpoint) Point inview :( uiview *) view withcontentview :( uiview *) cview;
-(Void) Dismiss;
@ End
# Import "dpoverview. H"
@ Interface dpoverview ()
@ Property (nonatomic, strong) uiview * contentview;
@ Property (nonatomic, assign) cgrect boxframe;
@ End
@ Implementation dpoverview
-(ID) initwithframe :( cgrect) Frame
{
Self = [Super initwithframe: frame];
If (Self ){
// Initialization code
Self. backgroundcolor = [uicolor clearcolor];
}
Return self;
}
+ (Void) showpoveratpoint :( cgpoint) Point inview :( uiview *) view withcontentview :( uiview *) cview
{
Dpopoverview * popview = [[dpoverview alloc] initwithframe: cgrectzero];
[Popview showpoveratpoint: Point inview: View withcontentview: cview];
}
-(Void) showpoveratpoint :( cgpoint) Point inview :( uiview *) view withcontentview :( uiview *) cview
{
Self. boxframe = cview. frame;
Self. contentview = cview;
Uiwindow * window = [uiapplication sharedapplication]. keywindow;
If (! Window ){
Window = [[uiapplication sharedapplication]. Windows objectatindex: 0];
}
Uiview * topview = window;
Cgpoint toppoint = [topview convertpoint: Point fromview: View];
Cgrect topviewbounds = topview. bounds;
_ Contentview. Frame = _ boxframe;
_ Contentview. Hidden = no;
[Self addsubview: _ contentview];
Self. layer. anchorpoint = cgpointmake (toppoint. X/topviewbounds. Size. Width, toppoint. Y/topviewbounds. Size. Height );
Self. Frame = topviewbounds;
[Self setneedsdisplay];
[Topview addsubview: Self];
Uitapgesturerecognizer * tap = [[uitapgesturerecognizer alloc] initwithtarget: Self action: @ selector (tapped :)];
[Self addgesturerecognizer: tap];
Self. userinteractionenabled = yes;
Self. Alpha = 0.f;
Self. Transform = cgaffinetransformmakescale (0.1f, 0.1f );
[Uiview animatewithduration: 0.2f delay: 0.f options: uiviewanimationoptioncurveeaseinout animations: ^ {
Self. Alpha = 1.f;
Self. Transform = cgaffinetransformmakescale (1.05f, 1.05f );
} Completion: ^ (bool finished ){
[Uiview animatewithduration: 0.08f delay: 0.f options: uiviewanimationoptioncurveeaseinout animations: ^ {
Self. Transform = cgaffinetransformidentity;
} Completion: Nil];
}];
}
// # Define kgradienttopcolor [uicolor colorwithwhite: 1.f ALPHA: 0.95]
// # Define kgradientbottomcolor [uicolor colorwithwhite: 0.98f ALPHA: 0.95]
# Define kgradienttopcolor [uicolor clearcolor]
# Define kgradientbottomcolor [uicolor clearcolor]
-(Void) drawrect :( cgrect) rect
{
// Drawing code
Cgrect frame = _ boxframe;
Float xmin = cgrectgetminx (FRAME );
Float ymin = cgrectgetminy (FRAME );
Float xmax = cgrectgetmaxx (FRAME );
Float Ymax = cgrectgetmaxy (FRAME );
Float radius = 4.f;
Float cpoffset = 1.8f;
Uibezierpath * popoverpath = [uibezierpath bezierpath];
[Popoverpath movetopoint: cgpointmake (cgrectgetminx (FRAME), cgrectgetminy (FRAME) + radius)]; //
[Popoverpath addcurvetopoint: cgpointmake (xmin + radius, ymin) controlpoint1: cgpointmake (xmin, ymin + radius-cpoffset) controlpoint2: cgpointmake (xmin + radius-cpoffset, ymin)]; //
[Popoverpath addlinetopoint: cgpointmake (xmax-radius, ymin)];
[Popoverpath addcurvetopoint: cgpointmake (xmax, ymin + radius) controlpoint1: cgpointmake (xmax-radius + cpoffset, ymin) controlpoint2: cgpointmake (xmax, ymin + radius-cpoffset)]; //
[Popoverpath addlinetopoint: cgpointmake (xmax, Ymax-radius)];
[Popoverpath addcurvetopoint: cgpointmake (xmax-radius, Ymax) controlpoint1: cgpointmake (xmax, Ymax-radius + cpoffset) controlpoint2: cgpointmake (xmax-radius + cpoffset, Ymax)]; //
[Popoverpath addlinetopoint: cgpointmake (xmin + radius, Ymax)];
[Popoverpath addcurvetopoint: cgpointmake (xmin, Ymax-radius) controlpoint1: cgpointmake (xmin + radius-cpoffset, Ymax) controlpoint2: cgpointmake (xmin, Ymax-radius + cpoffset)]; //
[Popoverpath closepath];
Cgcolorspaceref colorspace = cgcolorspacecreatedevicergb ();
Cgcontextref context = uigraphicsgetcurrentcontext ();
Uicolor * shadow = [uicolor colorwithwhite: 0.f ALPHA: 0.4f];
Cgsize shadowoffset = cgsizemake (0, 1 );
Cgfloat shadowblurradius = 10;
Nsarray * gradientcolors = [nsarray arraywithobjects:
(ID) kgradienttopcolor. cgcolor,
(ID) kgradientbottomcolor. cgcolor, nil];
Cgfloat gradientlocations [] = {0, 1 };
Cggradientref gradient = cggradientcreatewithcolors (colorspace, (cfarrayref) gradientcolors, gradientlocations );
Float bottomoffset = 0.f;
Float topoffset = 0.f;
Cgcontextsavegstate (context );
Cgcontextsetshadowwithcolor (context, shadowoffset, shadowblurradius, Shadow. cgcolor );
Cgcontextbegintransparencylayer (context, null );
[Popoverpath addclip];
Aggregate (context, gradient, cgpointmake (cgrectgetmidx (FRAME), cgrectgetminy (FRAME)-topoffset), cgpointmake (FRAME), cgrectgetmaxy (FRAME) + bottomoffset), 0 );
Cgcontextendtransparencylayer (context );
Cgcontextrestoregstate (context );
Cggradientrelease (gradient );
Cgcolorspacerelstrap (colorspace );
}
-(Void) tapped :( uitapgesturerecognizer *) tap
{
[Self dismiss];
}
-(Void) dismiss {
[Uiview animatewithduration: 0.3f animations: ^ {
Self. Alpha = 0.1f;
Self. Transform = cgaffinetransformmakescale (0.1f, 0.1f );
} Completion: ^ (bool finished ){
[Self removefromsuperview];
}];
}
@ End
Example:
{
Buttonselectcontrol * buttonselectcontrol _ = [[buttonselectcontrol alloc] initwithframe: cgrectmake (screenwidth-80, [utility getnavbarhight], 80, 80) Direction: Yes];
Buttonselectcontrol _. Delegate = self;
Buttonselectcontrol _. normalcolor = [uicolor colorwithred: 103/255. 0f Green: 103/255. 0f Blue: 103/255. 0f ALPHA: 1.0f];
Buttonselectcontrol _. selectcolor = [uicolor whitecolor];
Buttonselectcontrol _. fselfontsize = 12;
[Buttonselectcontrol _ setbackgroundcolor: maintitlebgcolor];
Cgfloat width, hight;
Width = buttonselectcontrol _. Frame. Size. width;
Hight = buttonselectcontrol _. Frame. Size. Height/3;
Uiedgeinsets edgeinset = uiedgeinsetsmake (0, 0, 15 );
Uibutton * btn0 = [[uibutton alloc] initwithframe: cgrectmake (0, 0, 80, 40)];
Btn0.imageedgeinsets = edgeinset;
[Btn0 setimage: [uiimage imagenamed: @ "QR code-up"] forstate: uicontrolstatenormal];
[Btn0 setimage: [uiimage imagenamed: @ "QR code-down"] forstate: uicontrolstatehighlighted];
[Btn0 settitle: @ "scan" forstate: uicontrolstatenormal];
[Btn0 settitle: @ "scan" forstate: uicontrolstatehighlighted];
[Btn0.titlelabel setfont: [uifont systemfontofsize: 16366f];
Btn0.tag = mv_btn_qrcode_tag;
[Buttonselectcontrol _ addbutton: btn0];
Uibutton * btn1 = [[uibutton alloc] initwithframe: cgrectmake (0, 40,
Cgrectgetwidth (btn0.frame ),
Cgrectgetheight (btn0.frame)];
[Btn1 setimage: [uiimage imagenamed: @ "ic_setting_up"] forstate: uicontrolstatenormal];
Btn1.imageedgeinsets = edgeinset;
[Btn1 settitle: @ "set" forstate: uicontrolstatenormal];
[Btn1 settitle: @ "set" forstate: uicontrolstatehighlighted];
[Btn1.titlelabel setfont: [uifont systemfontofsize: 16366f];
Btn1.tag = mv_btn_setting_tag;
[Buttonselectcontrol _ addbutton: btn1];
Dpopoverview * popoverview1 = [[dpopoverview alloc] initwithframe: cgrectzero];
Popoverview = popoverview1;
[Popoverview1 showpoveratpoint: cgpointmake (screenwidth-20, [utility getnavbarhight]/2) inview: Self. View withcontentview: buttonselectcontrol _];
}