ios - How to center multiple images in scrollview in Xcode/Swift -


i trying horizontally center 30 images in scrollview. best approach so? thanks.

enter image description here

edit: programmatically able create images, david cao, still having issue of not centering. thanks. enter image description here

if they're same image, why not programmatically? make loop , iterate through bounds.

nsinteger numwidth = 3; nsinteger numheight = 10; cgfloat border = 8; cgfloat width = (self.scrollview.frame.size.width - (numwidth + 1) * border)/3;  (nsinteger = 0; < numwidth; ++i) {     (nsinteger j = 0; j < numheight; ++j) {         uiimageview *imageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"imagenamehere"]];         imageview.frame = cgrectmake(border + width*i, border + width*j, width, width);         [self.scrollview addsubview:imageview];     } } [self.scrollview setcontentsize:cgsizemake(self.scrollview.frame.size.width, (border + width)*numheight + border]; 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -