Jugale Jugale - 1 month ago 14
iOS Question

Cocoa iOS Make CGPoints "Bigger" in UIView

Is it possible to make the default

CGPoint
size for an iOS app "bigger"?

For example, the iPhone's main view is 320 points wide - is it possible to change that to, say, 100 points, and base all calculations on that 100 (as in still be able to use
CGRectMake
, get sizes etc. normally).

So does anyone know how to subclass
UIView
in such a way as to make the above work, and, more importantly, would Apple allow it?

Thanks for your time!

Answer

Apply a CGAffineTransformMakeScale(320/100, 320/100) transform to your view so that it is scaled, and 100 points will be scaled to 100 * (320/100) = 320 points wide.

Or course, don't use magic numbers like above, but use some constant for the value 100 and something like [UIScreen mainScreen].applicationFrame.size.width (or view.window.screen.applicationFrame.size.width or anything similar) to get the width of the screen instead of the value 320 (because magic numbers are bad, and we never know if the size of the screen will change in any future like the height just changed with iPhone5)