xcode 是否可以将 UIScrollView 指示器从右侧移动到左侧?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11053336/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:37:00  来源:igfitidea点击:

is it possible to move the UIScrollView indicator from the right side to the left?

iosxcodeuiscrollview

提问by Nathan

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

谢谢你的时间

回答by Jeremy Jay

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

实际上,可以通过更改scrollIndicatorInsets属性将指示器限制在左侧的一个小区域内:

tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0,0,0,tableView.bounds.size.width-10);

回答by rickster

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

我喜欢 Jeremy Jay 的解决方案(虽然我还没有测试过),但只是为了彻底探索这个想法......这是另一个可能值得尝试的解决方案(尽管它也未经测试):

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 contentSizeset to match that of the "real" scroll view's. When the "real" scroll view's contentOffsetchanges (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.)

一个滚动视图(我们将其称为“真实”视图)包含您的内容,但隐藏了其指示器。另一个滚动视图不包含任何内容,但其contentSize设置与“真实”滚动视图的设置相匹配。当“真实”滚动视图的contentOffset更改(通过委托消息观察到)时,更改“假”滚动视图的偏移以匹配。(查看 WWDC 2012 的滚动视图会话,了解更多关于在没有内容视图的情况下使用滚动视图的想法。)

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.

理论上(同样,我还没有对此进行测试),您现在拥有一个与原始滚动视图分开的滚动指示器视图,您可以将它放置在与原始滚动视图相关的任何您喜欢的位置。将它放在原件的顶部并移动/调整它的大小,使其占据左侧的窄条,并且您有一个左侧滚动指示器。(或者,将其叠加在原件上,并使用仿射变换将其水平翻转。)将其完全放在其他地方,让您的 UI 带您去疯狂的小镇旅行。(或者不要。)不过,如果它在顶部分层,请确保您忽略触摸。

回答by Benhamine

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.

实现此目的的快速方法(如果您不使用行操作)而不必计算插图或弄乱其他表格视图,将是跨 Y 轴转换表格视图(翻转),然后将单元格转换回你明白了。

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

and then

进而

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