0

我想調整大小和重新定位模態視圖。調整大小運作良好。重新定位不起作用。有影子的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);  
} 

enter image description here

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

enter image description here

+1

您可能需要更改視圖的框架,而不是超級視圖的界限。 – fishinear

回答

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,而不是作爲第二步轉換。

相關問題