is it possible to move the UIScrollView indicator

2019-02-07 23:04发布

I realize I can rotate the cells and move the indicator by displaying the scroll view "upside down" but that requires a lot of other rotations, and manipulating of information to make the Table scroll properly.

Thanks for the time

3条回答
三岁会撩人
2楼-- · 2019-02-07 23:08

Actually, it is possible by changing the scrollIndicatorInsets property to restrict the indicator to a small area on the left side:

tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0,0,0,tableView.bounds.size.width-10);
查看更多
Anthone
3楼-- · 2019-02-07 23:13

I like Jeremy Jay's solution (though I haven't tested it), but just to thoroughly explore the idea... here's another that might be worth trying (though it's also untested):

Use two scroll views.

One scroll view (we'll call this the "real" one) contains your content but has its indicators hidden. Another scroll view contains no content but has its contentSize set to match that of the "real" scroll view's. When the "real" scroll view's contentOffset changes (as observed via delegate messages), change the "fake" scroll view's offset to match. (Check out the scroll views session from WWDC 2012 for more on the idea of using a scroll view without a content view.)

In theory (again, I haven't tested this), you now have a scroll indicator view that's separate from your original scroll view, and you can place it wherever you like in relation to the original. Layer it on top of the original and move/size it so it occupies a narrow sliver on the left, and you have a left-side scroll indicator. (Alternately, layer it atop the original and flip it horizontally with an affine transform.) Put it somewhere else entirely to take your UI on a trip to crazy town. (Or don't.) Make sure you make it ignore touches if it's layered on top, though.

查看更多
啃猪蹄的小仙女
4楼-- · 2019-02-07 23:24

A quick way to achieve this (if you're not using row actions) without having to calculate insets or messing with additional table views, would be to transform the table view across the Y-axis (flip) and then transform the cells back when you get them.

tableView.transform = CGAffineTransformMakeScale(1, -1);

and then

cell.transform = CGAffineTransformMakeScale(1, -1);
查看更多
登录 后发表回答