Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no minMarginPxBetweenItems #5

Open
Coco9077 opened this issue May 18, 2016 · 1 comment
Open

no minMarginPxBetweenItems #5

Coco9077 opened this issue May 18, 2016 · 1 comment

Comments

@Coco9077
Copy link

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 :)

@terenceLuffy
Copy link
Owner

terenceLuffy commented May 18, 2016

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)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants