Iphone 如何调整CALayer之后的大小';已添加为子层

Iphone 如何调整CALayer之后的大小';已添加为子层,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,我添加了一个CALayer(CAGradientLayer)作为UIImageView的子视图。我已经成功地将它添加为UIImageView的一个子层,但是在方向上我想调整层的宽度。我怎样才能做到?我尝试了以下代码,但没有成功: - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {

我添加了一个CALayer(CAGradientLayer)作为UIImageView的子视图。我已经成功地将它添加为UIImageView的一个子层,但是在方向上我想调整层的宽度。我怎样才能做到?我尝试了以下代码,但没有成功:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [self.imageOverlay setFrame:self.backgroundImageView_.bounds];
    [self.gradientOverlay setFrame:self.view.bounds];
}

您是否支持iOS 5?您可以覆盖视图控制器上的viewWillLayoutSubviews方法,并尝试在那里设置框架。否则,创建一个视图子类用作渐变层的容器,并在layoutSubviews中调整层的大小。

对不起,我的回答不是很清楚。。。因为你不需要支持iOS 4、3等等。。。可以在ViewWillLayoutSubView中手动调整图层的大小