AppStoreStyleHorizontalScrollView
AppStoreStyleHorizontalScrollView copied to clipboard
no minMarginPxBetweenItems
I have a problem, I created a uiview with image , but the minMarginPxBetweenItems can't be less than 0px . If I set minMarginPxBetweenItems = -8.0 ( between 0 and -7 not change nothing), the subviews overlap. How do I set no margin between items?
tnx :)
minMarginPxBetweenItems
is only the minimum margin between items, the actual margin would be depended on the scrollview and items size as well as the miniAppearPxOfLastItem
. You can see more details of how to calculate actual margin at calculateMarginBetweenItems
method
To achieve your target, you need to do little bit math. Firstly, set minMarginPxBetweenItems
to 0, then get the width of your items. For example, let's say your scrollview width is 300, if you don't want any item show in the right edge, set miniAppearPxOfLastItem
to 0, then the width of items should be (300-leftMarginPx
) / [numberOfItem you want to show, let's say 10] then the width should be (300-10)/10 = 29
horizontalScrollView.miniAppearPxOfLastItem = 0 //it can be any value
horizontalScrollView.leftMarginPx = 10
horizontalScrollView.miniMarginPxBetweenItems=0
horizontalScrollView.uniformItemSize = CGSizeMake((horizontalScrollView.frame.size.width-horizontalScrollView.leftMarginPx-horizontalScrollView.miniAppearPxOfLastItem)/10, 50)
...