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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With