Open tundsdev opened 9 years ago
Do you mean a pageEnabled UIScrollView but the pageWidth is smaller than the UIScrollView's frame? Actually you can and there are more than one solution. The simplest way I think is using a UICollectionView and implementing the UIScrollView delegate method scrollViewWillEndDragging: withVelocity:targetContentOffset:
to manually calculate the destination offset so that the collectionView appears to be pageEnabled
.
Question about converting your code to swift , the method scrollviewDidScroll () doesn't reach ahead after first if , always returns from there for me , your code works perfectly fine i have downloaded and checked it , Can you help me find where i'm going wrong. Here is the link to the same https://bitbucket.org/sourav13/infinitehorizontalscrolling. Please help me convert it into swift.
@sourav13, Sorry, been a little busy. I will have a look and reply ASAP.
@sourav13 It seems that Swift doesn't support function level static variable. The lastcontentOffsetX
in scrollViewDidScroll
has to be an outer scope variable. So the solution is
MainViewController
var lastcontentOffsetX = CGFloat(FLT_MIN)lastcontentOffsetX
in scrollViewDidScroll
@RungeZhai , Thank you for your precious time , your suggestion worked out for me.
Is there a way of implementing the cells so the cell stays in the middle but the cell on the left and right are previews half way similar to this