开发者

iphone: re-sizing gradient after shift from portrait to landscape

开发者 https://www.devze.com 2022-12-29 12:07 出处:网络
In viewDidLoad, I can create a gradient with no problem: CAGradientLayer *blueGradient = [[CAGradientLayer layer] retain];

In viewDidLoad, I can create a gradient with no problem:

CAGradientLayer *blueGradient = [[CAGradientLayer layer] retain]; blueGradient.frame = CGRectMake(gradientStartX,gradientStartY,gradientWidth,gradientHeight);

where gradientWith is device-defined as 320 or 1024 as appropriate.

What I can’t do is resize it inside willRotateToInterfaceOrientation: -– and thus get rid of that empty black space off to the right -- after the user changes to landscape mode. (The nav bar and tab bar behave nicely.)

(1) Recalibrating the gradient’s new dimensions according to the new mid-point, (2) using kCALayerMaxXMargin, and (3) employing bounds all looked like they would do the job. bounds looked a litte more intuitive, so I tried that.

I don’t want to admit that I have made zero progress.

I will say that I’ve been reduced to the brute force method of trying every permutation of self, view, layer, bounds, blueGradient, and CGRect(gradientStartX,gradientStartY,newGradientWidth,newGradientHeight) with zero success.

This is not difficult. 开发者_高级运维 My lack of understanding is making it difficult. Anyone out there “Been there, done that”?


Does the layer resize its size automatically? If so, simple

[blueGradient setNeedsDisplay];

should do the trick.

Hope this was helpful, Paul

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号