I want to resize and reposition modal view. Resize works well. Reposition doesn't work. There is bug with shadow. Please see screenshot number two. Is it possible to lower shadow?

-(IBAction) onModal:(id)sender
{
 UINavigationController *nav = [[UINavigationController alloc] init];
 nav.modalPresentationStyle = UIModalPresentationFormSheet;
 [self presentViewController:nav animated:YES completion:nil];

 nav.view.superview.bounds = CGRectMake(0, 0, 200, 200);    
}

enter image description here

nav.view.superview.bounds = CGRectMake(0, -200, 200, 200); 

enter image description here

有帮助吗?

解决方案

You can move the shadow around by setting the shadowPath attribute of the view's layer.

// be sure to include this and to link your app against it.
#import <QuartzCore/QuartzCore.h>
...

// UIBezierPath has nice convenience methods for creating rounded rectangles.
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0.f, 0.f, 200.f, 200.f) cornerRadius:4.f];

// Transform the path to your heart's content
[shadowPath applyTransform:CGAffineTransformMakeTranslation(0.f, 200.f)];

// use the CGPath method to get a CGPathRef for the layer's shadowPath
nav.view.superview.layer.shadowPath = shadowPath.CGPath;

note: Alternatively you could create the UIBezierPath with the offset you need rather than transforming as a second step.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top