Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the similar of linear layout in ios

I have many components in my view controller, and I want to combine them in a single object to scroll them together, what is the procedure to do it (like linearlayout in android) but I need it in IOS.

like image 308
CarinaM Avatar asked May 13 '13 12:05

CarinaM


2 Answers

iOS9 introduced something similar to LinearLayout: UiStackView

See this video from WWDC 2015: https://developer.apple.com/videos/wwdc/2015/?id=218

like image 154
DixieFlatline Avatar answered Sep 22 '22 02:09

DixieFlatline


Apple not provide linear container but you can use XHFLinearView at github

Usage Example:

XHFLinearView *linearView=[[XHFLinearView alloc]initWithFrame:self.view.bounds];
[self.view addSubview:linearView];
//init linear view content views
[linearView.itemSource addObject:XHFLinearViewUnitMake(someView, XHFMarginMake(0, 0, 0, 0))];
//force layout linear view
[linearView needLayout];
//insert a view with animation
[linearView insertItem:someView margin:XHFMarginMake(0, 0, 0, 0) atIndex:0 withAnimation:XHFLinearItemAnimationFade];
//replace a view with animation
[linearView replaceItem:someView withNewItem:newView withAnimation:XHFLinearItemAnimationFade];
//resize a view with animation
someView.frame=xxx;
[linearView needLayoutForItem:someView];
//remove a view with animation
[linearView removeItemByIndex:0 withAnimation:XHFLinearItemAnimationFade];
like image 43
xuhengfei Avatar answered Sep 22 '22 02:09

xuhengfei