Skip to content

Commit f19470a

Browse files
fix issue #44
1 parent 87fc511 commit f19470a

2 files changed

Lines changed: 65 additions & 5 deletions

File tree

WYPopoverController/WYPopoverController.m

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ - (void)sizzled_pushViewController:(UIViewController *)viewController animated:(
9393
if (self.isEmbedInPopover)
9494
{
9595
#ifdef WY_BASE_SDK_7_ENABLED
96-
viewController.edgesForExtendedLayout = UIRectEdgeNone;
96+
if ([viewController respondsToSelector:@selector(setEdgesForExtendedLayout:)])
97+
{
98+
viewController.edgesForExtendedLayout = UIRectEdgeNone;
99+
}
97100
#endif
98101
}
99102

@@ -328,6 +331,7 @@ @interface WYPopoverInnerView : UIView
328331

329332
@property (nonatomic, assign) CGFloat navigationBarHeight;
330333
@property (nonatomic, assign) BOOL wantsDefaultContentAppearance;
334+
@property (nonatomic, assign) CGFloat borderWidth;
331335

332336
@end
333337

@@ -352,6 +356,7 @@ @implementation WYPopoverInnerView
352356

353357
@synthesize navigationBarHeight;
354358
@synthesize wantsDefaultContentAppearance;
359+
@synthesize borderWidth;
355360

356361
- (id)initWithFrame:(CGRect)frame
357362
{
@@ -386,7 +391,7 @@ - (void)drawRect:(CGRect)rect
386391

387392
UIBezierPath* roundedRectPath = [UIBezierPath bezierPathWithRoundedRect:innerRect cornerRadius:cornerRadius + 1];
388393

389-
if (wantsDefaultContentAppearance == NO)
394+
if (wantsDefaultContentAppearance == NO && borderWidth > 0)
390395
{
391396
CGContextSaveGState(context);
392397
{
@@ -404,14 +409,19 @@ - (void)drawRect:(CGRect)rect
404409

405410
CGContextSaveGState(context);
406411
{
407-
if (wantsDefaultContentAppearance == NO)
412+
if (wantsDefaultContentAppearance == NO && borderWidth > 0)
408413
{
409414
[roundedRectPath addClip];
410415
CGContextSetShadowWithColor(context, innerShadowOffset, innerShadowBlurRadius, innerShadowColor.CGColor);
411416
}
412417

413418
UIBezierPath* inRoundedRectPath = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(innerRect, 0.5, 0.5) cornerRadius:cornerRadius];
414419

420+
if (borderWidth == 0)
421+
{
422+
inRoundedRectPath = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(innerRect, 0.5, 0.5) byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
423+
}
424+
415425
[self.innerStrokeColor setStroke];
416426
inRoundedRectPath.lineWidth = 1;
417427
[inRoundedRectPath stroke];
@@ -781,6 +791,7 @@ - (void)setViewController:(UIViewController *)viewController
781791
innerView.innerShadowOffset = innerShadowOffset;
782792
innerView.innerCornerRadius = self.innerCornerRadius;
783793
innerView.innerShadowBlurRadius = innerShadowBlurRadius;
794+
innerView.borderWidth = self.borderWidth;
784795
}
785796

786797
innerView.navigationBarHeight = navigationBarHeight;
@@ -835,6 +846,11 @@ - (CGFloat)innerCornerRadius
835846
if (borderWidth == 0)
836847
{
837848
result = 0;
849+
850+
if (outerCornerRadius > 0)
851+
{
852+
result = outerCornerRadius;
853+
}
838854
}
839855

840856
return result;
@@ -1015,6 +1031,18 @@ - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context
10151031

10161032
reducedOuterCornerRadius = MIN(reducedOuterCornerRadius, outerCornerRadius);
10171033

1034+
/*
1035+
if (borderWidth == 0 && outerCornerRadius > 0)
1036+
{
1037+
if ()
1038+
{
1039+
result = outerCornerRadius;
1040+
}
1041+
}
1042+
*/
1043+
1044+
NSLog(@"outerCornerRadius = %f", outerCornerRadius);
1045+
10181046
if (arrowDirection == WYPopoverArrowDirectionUp)
10191047
{
10201048
origin = CGPointMake(CGRectGetMidX(outerRect) + arrowOffset - arrowBase / 2, CGRectGetMinY(outerRect));
@@ -1603,7 +1631,12 @@ - (void)setPopoverNavigationBarBackgroundImage
16031631
if ([navigationController viewControllers] && [[navigationController viewControllers] count] > 0)
16041632
{
16051633
#ifdef WY_BASE_SDK_7_ENABLED
1606-
[(UIViewController *)[[navigationController viewControllers] objectAtIndex:0] setEdgesForExtendedLayout:UIRectEdgeNone];
1634+
UIViewController *firstViewController = (UIViewController *)[[navigationController viewControllers] objectAtIndex:0];
1635+
1636+
if ([firstViewController respondsToSelector:@selector(setEdgesForExtendedLayout:)])
1637+
{
1638+
[firstViewController setEdgesForExtendedLayout:UIRectEdgeNone];
1639+
}
16071640
#endif
16081641
}
16091642

demos/DemoSegue/WYPopoverDemoSegue/WYAppDelegate.m

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,39 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5858
[popoverAppearance setFillBottomColor:whyerColor];
5959
*/
6060

61-
UINavigationBar* navBarAppearance = [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], [WYPopoverBackgroundView class], nil];
61+
WYPopoverBackgroundView* popoverAppearance = [WYPopoverBackgroundView appearance];
62+
63+
[popoverAppearance setOuterCornerRadius:16];
64+
[popoverAppearance setOuterShadowBlurRadius:4];
65+
[popoverAppearance setOuterShadowOffset:CGSizeMake(0, 1)];
66+
67+
[popoverAppearance setGlossShadowColor:[UIColor clearColor]];
68+
[popoverAppearance setGlossShadowOffset:CGSizeMake(0, 0)];
69+
70+
[popoverAppearance setBorderWidth:0]; // Breaks
71+
[popoverAppearance setArrowHeight:12];
72+
[popoverAppearance setArrowBase:20];
73+
74+
[popoverAppearance setInnerCornerRadius:8];
75+
[popoverAppearance setInnerShadowBlurRadius:0];
76+
[popoverAppearance setInnerShadowColor:[UIColor clearColor]];
77+
[popoverAppearance setInnerShadowOffset:CGSizeMake(0, 0)];
78+
79+
UIColor *uniformColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
80+
81+
[popoverAppearance setFillTopColor:uniformColor];
82+
[popoverAppearance setFillBottomColor:uniformColor];
83+
[popoverAppearance setOuterStrokeColor:uniformColor];
84+
[popoverAppearance setInnerStrokeColor:uniformColor];
85+
86+
/*
87+
UINavigationBar *navBarAppearance = [UINavigationBar appearanceWhenContainedIn:[UINavigationController class], [WYPopoverBackgroundView class], nil];
6288
[navBarAppearance setTitleTextAttributes:@{
6389
UITextAttributeTextColor : [UIColor blackColor],
6490
UITextAttributeTextShadowColor: [UIColor clearColor],
6591
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetZero]
6692
}];
93+
*/
6794

6895
NSArray *temp = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"players" ofType:@"plist"]];
6996

0 commit comments

Comments
 (0)