Question: How to remove space occupied by a button by button click

Question

How to remove space occupied by a button by button click

Answers 1
Added at 2016-12-27 14:12
Tags
Question

I'm new to iOS. I want to know how to remove space occupied by a button instead of hiding the button.

first image

First I have 3 buttons. After clicking on button 2 I want to remove the space occupied by button 2 and change the position of button 3 position

final image

Answers
nr: #1 dodano: 2016-12-27 14:12

In order to do what you have explained in the image you can write your buttun2 action method like

-(IBAction)btn2Action:(UIButton *)sender
{
    button2.hidden = TRUE;
//    Change y value (if you have all three buttons in vertical) of button 3 Frame Like:
    CGRect btn3Frame = button3.frame;
    btn3Frame.origin.y = button2.frame.origin.y;
    button3.frame = btn3Frame;


//    Change x value (if you have all three buttons in Horizontal) of button 3 Frame Like:
    CGRect button3Frame = button3.frame;
    button3Frame.origin.x = button2.frame.origin.x;
    button3.frame = button3Frame;
}

If you got help from my answer then please accept it and up vote also.

Source Show
◀ Wstecz