ios - When adding more items to top of scrollview shift existing items down -
i'm trying add item top of scrollview while shifting down existing items. dont want remove existing views , re-add them.
this how i'm building scrollview:
for var index=0; index < data.users.count; index++ { if data.users[index] as! string != "" { let myimageview:uiimageview = uiimageview() myimageview.image = myimage myimageview.contentmode = uiviewcontentmode.scaleaspectfit myimageview.frame.size.width = imagewidth myimageview.frame.size.height = imageheight myimageview.frame.origin.x = 0 myimageview.frame.origin.y = myvariables.yposition self.myscrollview.addsubview(myimageview) myvariables.yposition += imageheight + spacer myvariables.scrollviewcontentsize+=imageheight + spacer self.mychatscrollview.contentsize = cgsize(width: imagewidth, height: myvariables.scrollviewcontentsize) }}
is there way can shift exisitng items down on scrollview when adding new item top?
// on button click, want shift down , add new item on top // without removing current views
to handle kind stuff better should using tableview handle things better when add remove , items.
if requirement use scroll view need step step .
first need move items down changing frame origin (y) this.
-run loop subviews , make view frame y + height of new one.
also make sure handle constraints if using auto layouts.
- if handle constrains better don't need move items if move top 1 rest handled.
- add new item animation when done moving other items.
Comments
Post a Comment