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

Posted by d_CFO on Stack Overflow See other posts from Stack Overflow or by d_CFO
Published on 2010-05-09T11:31:23Z Indexed on 2010/05/09 11:38 UTC
Read the original article Hit count: 160

Filed under:
|

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”?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about gradient