为什么UIView在offsetBy上向右移动

时间:2016-01-06 12:17:08

标签: ios swift uiview uiimageview

我有一个带有UIImageView的scrollview。当用户滚动时,我想将UIImageView保留在原始位置。我正在使用offsetBy:

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

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

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

1 个答案:

答案 0 :(得分:0)

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