@@ -144,6 +144,10 @@ - (NSString*)description
144144 {
145145 direction = @" RIGHT" ;
146146 }
147+ else if (arrowDirection == WYPopoverArrowDirectionNone)
148+ {
149+ direction = @" NONE" ;
150+ }
147151
148152 return [NSString stringWithFormat: @" %@ [ %f x %f ]" , direction, areaSize.width, areaSize.height];
149153}
@@ -995,7 +999,7 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
995999 reducedOuterCornerRadius = (CGRectGetMidX (outerRect) + arrowOffset - arrowBase / 2 ) - CGRectGetMinX (outerRect);
9961000 }
9971001 }
998- else
1002+ else if (arrowDirection == WYPopoverArrowDirectionLeft || arrowDirection == WYPopoverArrowDirectionRight)
9991003 {
10001004 if (arrowOffset >= 0 )
10011005 {
@@ -1077,6 +1081,23 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
10771081 CGPathAddLineToPoint (outerPathRef, NULL , origin.x , origin.y );
10781082 }
10791083
1084+ if (arrowDirection == WYPopoverArrowDirectionNone)
1085+ {
1086+ origin = CGPointMake (CGRectGetMaxX (outerRect), CGRectGetMidY (outerRect));
1087+
1088+ CGPathMoveToPoint (outerPathRef, NULL , origin.x , origin.y );
1089+
1090+ CGPathAddLineToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMidY (outerRect));
1091+ CGPathAddLineToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMidY (outerRect));
1092+
1093+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMaxY (outerRect), CGRectGetMinX (outerRect), CGRectGetMaxY (outerRect), outerCornerRadius);
1094+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMinX (outerRect), CGRectGetMaxY (outerRect), CGRectGetMinX (outerRect), CGRectGetMinY (outerRect), outerCornerRadius);
1095+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMinX (outerRect), CGRectGetMinY (outerRect), CGRectGetMaxX (outerRect), CGRectGetMinY (outerRect), outerCornerRadius);
1096+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMinY (outerRect), CGRectGetMaxX (outerRect), CGRectGetMaxY (outerRect), outerCornerRadius);
1097+
1098+ CGPathAddLineToPoint (outerPathRef, NULL , origin.x , origin.y );
1099+ }
1100+
10801101 CGPathCloseSubpath (outerPathRef);
10811102
10821103 UIBezierPath* outerRectPath = [UIBezierPath bezierPathWithCGPath: outerPathRef];
@@ -1821,6 +1842,24 @@ - (void)positionPopover
18211842 containerView.arrowOffset = offset;
18221843 }
18231844
1845+ if (arrowDirection == WYPopoverArrowDirectionNone)
1846+ {
1847+ containerView.arrowDirection = WYPopoverArrowDirectionNone;
1848+ containerViewSize = [containerView sizeThatFits: contentViewSize];
1849+
1850+ containerFrame = CGRectZero;
1851+ containerFrame.size = containerViewSize;
1852+ containerFrame.size .width = MIN (maxX - minX, containerFrame.size .width );
1853+ containerFrame.size .height = MIN (maxY - minY, containerFrame.size .height );
1854+ containerView.frame = containerFrame;
1855+
1856+ containerView.center = CGPointMake (minX + (maxX - minX) / 2 , minY + (maxY - minY) / 2 );
1857+
1858+ containerFrame = containerView.frame ;
1859+
1860+ containerView.arrowOffset = offset;
1861+ }
1862+
18241863 containerView.frame = containerFrame;
18251864
18261865 containerView.wantsDefaultContentAppearance = wantsDefaultContentAppearance;
@@ -1965,6 +2004,14 @@ - (WYPopoverArrowDirection)arrowDirectionForRect:(CGRect)aRect
19652004 area.arrowDirection = WYPopoverArrowDirectionRight;
19662005 [areas addObject: area];
19672006 }
2007+
2008+ if ((arrowDirections & WYPopoverArrowDirectionNone) == WYPopoverArrowDirectionNone)
2009+ {
2010+ area = [[WYPopoverArea alloc ] init ];
2011+ area.areaSize = [self sizeForRect: aRect inView: aView arrowHeight: arrowHeight arrowDirection: WYPopoverArrowDirectionNone];
2012+ area.arrowDirection = WYPopoverArrowDirectionNone;
2013+ [areas addObject: area];
2014+ }
19682015
19692016 if ([areas count ] > 1 )
19702017 {
@@ -2080,6 +2127,11 @@ - (CGSize)sizeForRect:(CGRect)aRect
20802127 result.height = maxY - (viewFrame.origin .y + viewFrame.size .height );
20812128 result.height -= arrowHeight;
20822129 }
2130+ else if (arrowDirection == WYPopoverArrowDirectionNone)
2131+ {
2132+ result.width = maxX - minX;
2133+ result.height = maxY - minY;
2134+ }
20832135
20842136 return result;
20852137}
0 commit comments