I am using IOS 5. I am a very beginner in IOS. In my project i have 2 xib files. One is a UIView and other is a UIViewcotroller. The UIViewcontroller is having 3 views(TopBar,ContentArea,BottomBar). uiview also has 3 subviews. I added UIView as subview of UIViewController. My requirement is change the UIView height when i hide topbar only, bottombar only, topbar and bottombar.

Hope you can help me.

Thanks in advance.

有帮助吗?

解决方案

set the views as properties,

@property (nonatomic, retain)UIView *element1_p1;

then when you need to change the size, change the frame,

self.element1_p1.frame = CGRectMake(center.x,
                                    center.y,
                                    elementWidth, elementHeight);

I recommend doing an animation for the change of height, so it feels better UX

great tutorial for changing views properties with animation

其他提示

UIView has method as setFrame to resize the view.

Read this and this - you will get an idea how subviews respond to parent view's frame changes.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top