【问题标题】:Why is UIView moved to right on offsetBy为什么 UIView 在 offsetBy 上向右移动
【发布时间】:2016-01-06 12:17:07
【问题描述】:

我有一个带有 UIImageView 的滚动视图。当用户滚动时,我想将 UIImageView 保持在原来的位置。我为此使用了 offsetBy:

func scrollViewDidScroll(scrollView: UIScrollView) {
    let offset = scrollView.contentOffset.y

    self.headerView!.currentLoadLabel.frame = currentLoadLabelFrame.offsetBy(dx: 0, dy: offset)
}

UIImageView 停留在他的 y 位置,但移动到屏幕右侧最远的 x 位置。为什么?

【问题讨论】:

    标签: ios swift uiview uiimageview


    【解决方案1】:

    试试下面的代码: self.headerView!.currentLoadLabel.frame = currentLoadLabelFrame.offsetBy(dx: scrollView.contentOffset.x, dy: scrollView.contentOffset.y)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      • 2015-05-26
      • 1970-01-01
      • 2019-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多