Centering an image in IOS

Just been struggling to update flagSter to support the new iPhone5 screen. Issue was horizontally centering the flag image when in landscape mode. This was because the screen width varies between iPhone and iPhone5 when in that orientation.

Quickest/easiest method was discovered, wherelse, in Stack Overflow. Thanks Damo.

CGPoint center = myImage.center;
center.x = self.view.center.x;
myImage.center = center;

Best part of this solution, other than its simplicity, is it is not that difficult to determine how you could possible sort out the vertical orientation too!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>