0

我想调整和重新定位模态视图。调整大小效果很好。重新定位不起作用。有阴影的错误。请看截图二。是否可以降低阴影?

-(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);    
}

在此处输入图像描述

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

在此处输入图像描述

4

1 回答 1

2

您可以通过设置视图层的 shadowPath 属性来移动阴影。

// 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;

注意:或者,您可以使用所需的偏移量创建 UIBezierPath,而不是作为第二步进行转换。

于 2012-12-01T20:07:37.327 回答