Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scale UIView and all its children

I have an UIView with around 50 UIButtons. All button positions were given in pixels, relative to the left upper corner of my main UIView.

All (background) images used in the view are available in higher resolution. As I am porting my app from iPhone to iPad, I would like to increase the effective pixel size of the UIView.

Now I'm searching a way to upscale the whole UIView by a factor of 2*. Is that possible without destroying the position of the inner elements?

FYI, the UIView is designed in a NIB-file in XCode. But I don't mind if it can be done programmatically.

like image 927
andreas Avatar asked Feb 04 '13 23:02

andreas


People also ask

What is a UIView?

An object that manages the content for a rectangular area on the screen. Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views.

Why do I need glkview instead of UIView?

Because it waits until the next drawing cycle to update the view, you can call these methods on multiple views to update them at the same time. If you are using OpenGL ES to do your drawing, you should use the GLKView class instead of subclassing UIView.

What is the difference between UIView and a view object?

A view object renders content within its bounds rectangle and handles any interactions with that content. The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.

What are animations in UIView?

Animations are another way to make visible changes to a view without requiring you to subclass and implement complex drawing code. Many properties of the UIView class are animatable, which means changes to those properties can trigger system-generated animations.


1 Answers

I ended up using

self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 2, 2); 

It allowed me to keep the design created in the Interface Builder.

Unfortunately the sharpness of the image suffers in that case, but this is a small price to pay compared to scripting the whole design programmatically.

like image 143
andreas Avatar answered Sep 22 '22 23:09

andreas