ios hide ui element and unblock space

764 views Asked by At

I have an ui design with a pageviewcontroller in a storyboard with autolayout activated. The design consists of several labels and some images for each page. on some pages some labels should not be visible (beacause there is no information to display). I just can hide the ui element but than I get a visible gap between the ui elements.

What is the easiest way to hide a ui element and unblock the space of it? Like "GONE" in android.

1

There are 1 answers

0
Jason McDermott On

One way to do this is to move (with/without animation) the remaining visible UI components when you want to hide one of them. Give this a try:

CGRect newFrame = theView.frame;
newFrame.origin.x += 500;    // shift right by 500pts

[UIView animateWithDuration:1.0 
    animations:^{
        theView.frame = newFrame;
    }];

The above snippet (and other examples) can be found here.