Я столкнулся с тем же препятствием, так как все виды являются идентифицируемыми, вы сможете выбирать вид по идентификатору и корректировать его смещение содержимого, так как IDView
инициализируется с помощью id
, а большинство представлений имеют .id()
метод и установит значение идентификатора для представления, пока нет способа получить представление по его идентификатору, или, может быть, я еще не понял его, полагаю, что они могут добавить новый метод к List
, чтобы определить scrollDirection
но это всего лишь предположение, в любом случае вам понадобится X, Y представления в этом ScrollView, а затем настроить его в соответствии с его родителем, также вы можете проверить метод .position()
.
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Returns a uniquely identified view that can be inserted or
/// removed.
@inlinable public func id<ID>(_ id: ID) -> IDView<Self, ID> where ID : Hashable
}
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {
/// Fixes the center of this view at the specified point in its parent's
/// coordinate space.
///
/// - Parameter position: The point at which to place the center of this
/// view.
/// - Returns: A view that fixes the center of this view at `position`.
@inlinable public func position(_ position: CGPoint) -> Self.Modified<_PositionLayout>
/// Fixes the center of this view at the specified coordinates in its
/// parent's coordinate space.
///
/// - Parameters:
/// - x: The x-coordinate at which to place the center of this view.
/// - y: The y-coordinate at which to place the center of this view.
/// - Returns: A view that fixes the center of this view at
/// `x` and `y`.
@inlinable public func position(x: Length = 0, y: Length = 0) -> Self.Modified<_PositionLayout>
}