@@ -148,8 +148,10 @@ - (void)layoutSubviews
148148 self.cellScrollView .frame = CGRectMake (0 , 0 , CGRectGetWidth (self.bounds ), self.height );
149149 self.cellScrollView .contentSize = CGSizeMake (CGRectGetWidth (self.bounds ) + [self utilityButtonsPadding ], self.height );
150150 self.cellScrollView .contentOffset = CGPointMake ([self leftUtilityButtonsWidth ], 0 );
151- self.scrollViewButtonViewLeft .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 , [self leftUtilityButtonsWidth ], self.height );
152- self.scrollViewButtonViewRight .frame = CGRectMake (CGRectGetWidth (self.bounds ), 0 , [self rightUtilityButtonsWidth ], self.height );
151+ self.scrollViewButtonViewLeft .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 , 0 , self.height );
152+ self.scrollViewButtonViewLeft .layer .masksToBounds = YES ;
153+ self.scrollViewButtonViewRight .frame = CGRectMake (CGRectGetWidth (self.bounds ), 0 , 0 , self.height );
154+ self.scrollViewButtonViewRight .layer .masksToBounds = YES ;
153155 self.scrollViewContentView .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 , CGRectGetWidth (self.bounds ), self.height );
154156 self.cellScrollView .scrollEnabled = YES ;
155157 self.containingTableView .scrollEnabled = YES ;
@@ -538,13 +540,27 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
538540 self.tapGestureRecognizer .enabled = NO ;
539541 if (scrollView.contentOffset .x > [self leftUtilityButtonsWidth ])
540542 {
543+ CGFloat scrollViewWidth = MIN (scrollView.contentOffset .x - [self leftUtilityButtonsWidth ], [self rightUtilityButtonsWidth ]);
544+
541545 // Expose the right button view
542- self.scrollViewButtonViewRight .frame = CGRectMake (scrollView.contentOffset .x + (CGRectGetWidth (self.bounds ) - [self rightUtilityButtonsWidth ]), 0 .0f , [self rightUtilityButtonsWidth ], self.height );
546+ self.scrollViewButtonViewRight .frame = CGRectMake (scrollView.contentOffset .x + (CGRectGetWidth (self.bounds ) - scrollViewWidth), 0 .0f , scrollViewWidth,self.height );
547+
548+ CGRect scrollViewBounds = self.scrollViewButtonViewRight .bounds ;
549+ scrollViewBounds.origin .x = MAX ([self rightUtilityButtonsWidth ] - scrollViewWidth, [self rightUtilityButtonsWidth ] - scrollView.contentOffset .x );
550+ self.scrollViewButtonViewRight .bounds = scrollViewBounds;
551+
543552 }
544553 else
545554 {
555+ CGFloat scrollViewWidth = MIN (scrollView.contentOffset .x - [self leftUtilityButtonsWidth ], [self leftUtilityButtonsWidth ]);
556+
546557 // Expose the left button view
547- self.scrollViewButtonViewLeft .frame = CGRectMake (scrollView.contentOffset .x , 0 .0f , [self leftUtilityButtonsWidth ], self.height );
558+ self.scrollViewButtonViewLeft .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 .0f , scrollViewWidth, self.height );
559+
560+ CGPoint offset = scrollView.contentOffset ;
561+ offset.x = MAX (0 , scrollView.contentOffset .x );
562+
563+ scrollView.contentOffset = offset;
548564 }
549565 }
550566 else
0 commit comments