简体   繁体   English

Swift scrollToRow然后突出显示该行

[英]Swift scrollToRow then highlight that row

What I would like to do is scrollToRow, then animate the background of that row so it's background changes visibly, so the user can see that exact row. 我想做的是scrollToRow,然后对该行的背景进行动画处理,以便其背景发生明显变化,以便用户可以看到确切的行。

I have a table with ~100 rows, and when scrollToRow is triggered, it scrolls to the right row, but it gets lost in the other rows. 我有一个约100行的表,当触发scrollToRow时,它滚动到右行,但在其他行中丢失。 I just want the user to have the ability to spot that row more easily... 我只是希望用户能够更轻松地发现该行...

You can use, any of following solutions, all them works fine: 您可以使用以下任何一种解决方案,它们都可以正常工作:

scrollToRow(at:at:animated:) scrollToRow(在:在:动画:)

Scrolls through the table view until a row identified by index path is at a particular location on the screen. 滚动浏览表视图,直到由索引路径标识的行位于屏幕上的特定位置。

func scrollToRow(at indexPath: IndexPath, at scrollPosition: UITableViewScrollPosition, animated: Bool)

scrollToNearestSelectedRow(at:animated:) scrollToNearestSelectedRow(在:动画:)

Scrolls the table view so that the selected row nearest to a specified position in the table view is at that position. 滚动表格视图,以使最接近表格视图中指定位置的选定行位于该位置。

func scrollToNearestSelectedRow(at scrollPosition: UITableViewScrollPosition, animated: Bool)

scrollRectToVisible(_:animated:) scrollRectToVisible(_:动画:)

Scrolls a specific area of the content so that it is visible in the receiver. 滚动内容的特定区域,以便在接收器中可见。 Use scrollview of tableview to achieve this result 使用tableview的scrollview来实现此结果

func scrollRectToVisible(_ rect: CGRect, animated: Bool)

selectRow(at:animated:scrollPosition:) selectRow(在:动画::)的scrollPosition

Selects a row in the table view identified by index path, optionally scrolling the row to a location in the table view. 在表视图中选择由索引路径标识的行,还可以选择将该行滚动到表视图中的某个位置。

func selectRow(at indexPath: IndexPath?, animated: Bool, scrollPosition: UITableViewScrollPosition)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM