ermalkaleci / CarbonKit

CarbonKit - iOS Components (Obj-C & Swift)
MIT License
682 stars 163 forks source link

Prevent navigation items from bouncing left and right #188

Closed kristiyandobrev closed 7 years ago

kristiyandobrev commented 7 years ago

I have my CarbonTabSwipeNavigation like:

private(set) lazy var tabSwipeNavigation: CarbonTabSwipeNavigation = {
        let segmentControlWidth = UIScreen.main.bounds.size.width / CGFloat(self.tabPagerNavigationItems.count)
        let carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: self.tabPagerNavigationItems, delegate: self)
        carbonTabSwipeNavigation.carbonSegmentedControl?.backgroundColor = .white
        for (index, element) in self.tabPagerNavigationItems.enumerated() {
            carbonTabSwipeNavigation.carbonSegmentedControl?.setWidth(segmentControlWidth, forSegmentAt: index)
        }
        carbonTabSwipeNavigation.setNormalColor(someColor)
        carbonTabSwipeNavigation.setSelectedColor(someColor2)
        carbonTabSwipeNavigation.setIndicatorColor(someColor3)
        carbonTabSwipeNavigation.setIndicatorHeight(2)
        return carbonTabSwipeNavigation
    }()

And it looks like:

screen shot 2017-10-10 at 08 32 39

The problem is that the items with the icons are bouncing left or right whenever I try to scroll them, meaning that the items are going off the screen:

test

I have tried to to add carbonTabSwipeNavigation.pagesScrollView?.bounces = false but that only prevents the swiping to to the next coontroller in the carbonTabSwipeNavigation.

Any ideas if disabling the bouncing of the navigation items is possible ?

ermalkaleci commented 7 years ago

@kristiyandobrev It seems like a bug. Please can you share your project environment (iOS, xCode)?

kristiyandobrev commented 7 years ago

iOS 11.* and XCode 9.*

ermalkaleci commented 7 years ago

can't reproduce it. can you record your screen?

kristiyandobrev commented 7 years ago

Alright. I managed to solve it. I had to add carbonTabSwipeScrollView.isScrollEnabled = false. It is undoubtedly a really simple fix but unfortunately undocumented.