Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do expand and collapse uiview on IOS [closed]

Tags:

ios

iphone

I am very new to iPhone/iPad development. can you please help me create this programmatically. I want to expand/collapse a UIView programmatically.

Anyone know how to do it or any tutorial that i can follow? I have tried to find the tutorial but couldn't find what i want.

Below is the screenshot how i want to do

enter image description here

like image 805
shhrzl Avatar asked Sep 26 '13 07:09

shhrzl


1 Answers

Its easily done with modify the height of that View as bneely suggested..

Follow the below steps:

1.First create the second View what you posted in your question and name it "detailedView"

2.if you have the "detailedView" height = 200(for example), write the following code in viewDidLoad method,

  CGRect newFrame = detailedView.frame; 

  newFrame.size.height = 100;

  detailedView.frame = newFrame;

so when the "detailedView" load, it will be looked like the first View what you showed in your question.

3.When you click the button to expand "detailedView", within that button action just write the following code

  CGRect newFrame = detailedView.frame;

  if(newFrame.size.height == 100)
  {
         newFrame.size.height = 200;
         [UIView animateWithDuration:0.25 animations:^(void){
         detailedView.frame = newFrame;
         }];
  }
  else
  {
         newFrame.size.height = 100;
          [UIView animateWithDuration:0.25 animations:^(void){
          detailedView.frame = newFrame;
          }];
  }

That's all.

like image 145
Palani Jacob Avatar answered Sep 18 '22 14:09

Palani Jacob