@@ -1009,6 +1009,22 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
10091009
10101010 reducedOuterCornerRadius = MIN (reducedOuterCornerRadius, outerCornerRadius);
10111011
1012+ if (arrowDirection == WYPopoverArrowDirectionNone)
1013+ {
1014+ origin = CGPointMake (CGRectGetMidX (outerRect), CGRectGetMinY (outerRect));
1015+
1016+ CGPathMoveToPoint (outerPathRef, NULL , origin.x , origin.y );
1017+
1018+ CGPathAddLineToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect) - outerCornerRadius, CGRectGetMinY (outerRect));
1019+
1020+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMinY (outerRect), CGRectGetMaxX (outerRect), CGRectGetMaxY (outerRect), outerCornerRadius);
1021+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMaxX (outerRect), CGRectGetMaxY (outerRect), CGRectGetMinX (outerRect), CGRectGetMaxY (outerRect), outerCornerRadius);
1022+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMinX (outerRect), CGRectGetMaxY (outerRect), CGRectGetMinX (outerRect), CGRectGetMinY (outerRect), outerCornerRadius);
1023+ CGPathAddArcToPoint (outerPathRef, NULL , CGRectGetMinX (outerRect), CGRectGetMinY (outerRect), CGRectGetMaxX (outerRect), CGRectGetMinY (outerRect), outerCornerRadius);
1024+
1025+ CGPathAddLineToPoint (outerPathRef, NULL , origin.x , origin.y );
1026+ }
1027+
10121028 if (arrowDirection == WYPopoverArrowDirectionUp)
10131029 {
10141030 origin = CGPointMake (CGRectGetMidX (outerRect) + arrowOffset - arrowBase / 2 , CGRectGetMinY (outerRect));
@@ -1214,7 +1230,7 @@ - (CGRect)arrowRect:(CGRect)rect arrowDirection:(WYPopoverArrowDirection)aArrowD
12141230{
12151231 CGRect result = CGRectZero;
12161232
1217- if (arrowHeight > 0 )
1233+ if (arrowHeight > 0 && aArrowDirection != WYPopoverArrowDirectionDown )
12181234 {
12191235 result.size = CGSizeMake (arrowBase, arrowHeight);
12201236
@@ -1414,17 +1430,27 @@ - (CGSize)contentSizeForViewInPopover
14141430{
14151431 CGSize result = CGSizeZero;
14161432
1433+ UIViewController *controller = viewController;
1434+
1435+ UINavigationController *navigationController = (UINavigationController *)controller;
1436+ if ([[navigationController viewControllers ] count ] > 0 )
1437+ {
1438+ controller = (UIViewController *)[[navigationController viewControllers ] objectAtIndex: 0 ];
1439+ }
1440+
14171441#ifdef WY_BASE_SDK_7_ENABLED
1418- if ([viewController respondsToSelector: @selector (preferredContentSize )])
1442+ if ([controller respondsToSelector: @selector (preferredContentSize )])
14191443 {
1420- result = viewController .preferredContentSize ;
1444+ result = controller .preferredContentSize ;
14211445 }
14221446#endif
1447+
14231448 if (CGSizeEqualToSize (result, CGSizeZero))
14241449 {
14251450#pragma clang diagnostic push
14261451#pragma GCC diagnostic ignored "-Wdeprecated"
1427- result = viewController.contentSizeForViewInPopover ;
1452+
1453+ result = controller.contentSizeForViewInPopover ;
14281454#pragma clang diagnostic pop
14291455 }
14301456
@@ -1604,7 +1630,7 @@ - (void)positionPopover
16041630
16051631 overlayView.frame = self.rootView .bounds ;
16061632
1607- viewFrame = [overlayView convertRect: rect fromView: inView];
1633+ viewFrame = (permittedArrowDirections != WYPopoverArrowDirectionNone) ? [overlayView convertRect: rect fromView: inView] : overlayView. bounds ;
16081634
16091635 minX = popoverLayoutMargins.left ;
16101636 maxX = self.rootView .bounds .size .width - popoverLayoutMargins.right ;
@@ -1821,6 +1847,24 @@ - (void)positionPopover
18211847 containerView.arrowOffset = offset;
18221848 }
18231849
1850+ if (arrowDirection == WYPopoverArrowDirectionNone)
1851+ {
1852+ containerView.arrowDirection = WYPopoverArrowDirectionNone;
1853+ containerViewSize = [containerView sizeThatFits: contentViewSize];
1854+
1855+ containerFrame = CGRectZero;
1856+ containerFrame.size = containerViewSize;
1857+ containerFrame.size .width = MIN (maxX - minX, containerFrame.size .width );
1858+ containerFrame.size .height = MIN (maxY - minY, containerFrame.size .height );
1859+ containerView.frame = containerFrame;
1860+
1861+ containerView.center = CGPointMake (viewFrame.size .width / 2 , viewFrame.size .height / 2 );
1862+
1863+ containerFrame = containerView.frame ;
1864+
1865+ containerView.arrowOffset = 0 ;
1866+ }
1867+
18241868 containerView.frame = containerFrame;
18251869
18261870 containerView.wantsDefaultContentAppearance = wantsDefaultContentAppearance;
@@ -1931,8 +1975,13 @@ - (WYPopoverArrowDirection)arrowDirectionForRect:(CGRect)aRect
19311975{
19321976 WYPopoverArrowDirection arrowDirection = WYPopoverArrowDirectionUnknown;
19331977
1934- NSMutableArray * areas = [NSMutableArray arrayWithCapacity: 0 ];
1935- WYPopoverArea* area;
1978+ if (arrowDirections == WYPopoverArrowDirectionNone)
1979+ {
1980+ arrowDirection = WYPopoverArrowDirectionNone;
1981+ }
1982+
1983+ NSMutableArray *areas = [NSMutableArray arrayWithCapacity: 0 ];
1984+ WYPopoverArea *area;
19361985
19371986 if ((arrowDirections & WYPopoverArrowDirectionDown) == WYPopoverArrowDirectionDown)
19381987 {
0 commit comments