在这里您可以看到,更新框架后,UIScrollview在其内容大小的底部滚动时遇到了问题。
我试图删除以下两行代码:
这个: scrBuilds.frame = CGRect(x:0,y:140,宽度:scrBuilds.frame.width,高度:self.view.frame.height-140)
这个: scrBuilds.frame = CGRect(x:0,y:235,宽度:scrBuilds.frame.width,高度:self.view.frame.height-235)
除去这两行后,我看不到卡住的问题,但是scrBuilds的框架没有得到有效更新。这是我的代码。
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offset = self.scrBuilds.contentOffset.y
if offset > 0 {
if offset < 60 {
filterView.frame = CGRect(x: 0, y: 20 - offset, width: filterView.frame.width, height: 60)
self.scrCategory.transform = CGAffineTransform(scaleX: 1, y: 1)
scrCategory.frame = CGRect(x: 0, y: 80 - offset, width: scrCategory.frame.width, height: 155)
}
if offset >= 60 && offset < 95 {
filterView.frame = CGRect(x: 0, y: -40, width: filterView.frame.width, height: 60)
self.scrCategory.transform = CGAffineTransform(scaleX: (215 - offset) / 155, y: (215 - offset) / 155)
scrCategory.frame = CGRect(x: 0, y: 20, width: scrCategory.frame.width, height: 215 - offset)
}
if offset >= 95 {
filterView.frame = CGRect(x: 0, y: -40, width: filterView.frame.width, height: 60)
self.scrCategory.transform = CGAffineTransform(scaleX: 120 / 155, y: 120 / 155)
scrCategory.frame = CGRect(x: 0, y: 20, width: scrCategory.frame.width, height: 120)
scrBuilds.frame = CGRect(x: 0, y: 140, width: scrBuilds.frame.width, height: self.view.frame.height - 140)
}else {
scrBuilds.frame = CGRect(x: 0, y: 235 - offset, width: scrBuilds.frame.width, height: self.view.frame.height - 235 + offset)
}
}else {
filterView.frame = CGRect(x: 0, y: 20, width: filterView.frame.width, height: 60)
self.scrCategory.transform = CGAffineTransform(scaleX: 1, y: 1)
scrCategory.frame = CGRect(x: 0, y: 80, width: scrCategory.frame.width, height: 155)
scrBuilds.frame = CGRect(x: 0, y: 235, width: scrBuilds.frame.width, height: self.view.frame.height - 235)
}
}
我想让scrBuilds永不停滞,并有效地更新其框架。请帮帮我。