我想调整大小并重新定位模态视图。调整大小效果很好。重新定位不起作用。有阴影的bug。请看截图二。是否可以降低阴影?
-(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);
答案 0 :(得分: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,而不是转换为第二步。