views:

97

answers:

1

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

A: 

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

[blueGradient setNeedsDisplay];

should do the trick.

Hope this was helpful, Paul

Pawel
And you set resizing by either using the "springs and struts" view in IB, or setting the views contentMode property.
Paul Lynch
Paul -- Nope, no IB. I'm not doing anything with contentMode either. As we say on this side of the pond, "plain vanilla."Pawel -- [blueGradient setNeedsDisplay] results in "blueGradient undeclared" Both -- Wow, fast responses! Thank you.
d_CFO
The blueGradient is the reference to your gradient layer - you need to keep in order to call it when the rotation is finished.
Pawel