tags:

views:

130

answers:

2

Currently I am doing it like this:

CGRect frameRect = myUIImageView.frame;
CGPoint rectPoint = frameRect.origin;
CGFloat newXPos = rectPoint.x + 10.5f;
landscape.frame = CGRectMake(newXPos, 0.0f, myUIImageView.frame.size.width, landscape.frame.size.height);

it feel that there is a more efficient solution. Maybe by using the center point?

+2  A: 

Yes, you can move the center but the code is not significnaly more efficient. You could optimise out the CGPoint and assign the rect back directly:

CGRect frameRect = myUIImageView.frame; 
frameRect.origin.x += 10.5f;
landscape.frame = frameRect;

For that matter, you could just adjust the frame directly but, the optimiser will likely do this for you anyway.

What specifically are you not happy with? This doesn't seem like a good target to optimise. If your app's display is updating slowly, I suspect you are doing something else wrong.

Roger Nolan
Thanks. Oh no, it's all fine with my app. I just wondered if that would cause problems in situations where I move a lot more stuff, since Apple says that moving the center point is the way to go. Although I wouldn't like to think about calculating coordinates from the perspective of the center point. I guess you're right. Thanks.
Thanks
moving the center isn't that different because views have a center property.
Roger Nolan
A: 

I put my 'moving around stuff' in an animation block, and let the iPhone do the moving.

MiRAGe