uiscrollview - 迅速。设置 UIScrollView 的 contentInset 不起作用
问题描述
我有一个 UIView,上面有一个 UIScrollView。
let curtainView = UIScrollView ()
curtainView.snp.makeConstraints {make in
make.edges.equalToSuperview ()
}
还有 UIView。
let someView = UIView ()
someView.snp.makeConstraints {make in
make.top.equalToSuperview (). offset (10)
make.leading.trailing.equalToSuperview (). inset (10)
}
Objective: 根据 UIView 的可见性为 UIScrollView 设置 contentInset。UIView 的可见性通过 RxSwift 改变。我正在做以下事情
override func layoutSubviews () {
super.layoutSubviews ()
curtainView.contentInset.top = someView.isHidden? self.frame.minY: someView.frame.maxY
}
layoutSubviews 方法被多次调用:
1.curtainView.contentInset.top == 0
2.curtainView.contentInset.top == 0
3.curtainView.contentInset.top == 30
然而,视觉上 someView 的 contentInset 保持不变。只有在滑动之后,窗帘才会设置正确的缩进。我无权添加图片,请在第三方资源上查看:https ://youtu.be/LecHmLd9HP4
解决方案
推荐阅读
- numpy - TFRecord 读取和内存使用情况
- flutter - 如何在 Flutter 中理想地在同一个项目下创建多个应用程序?
- arrays - Lua - 从字符串数组生成随机哈希 id
- spring-boot - repeatWhenEmpty 运算符在 RSocket websocket 请求的上下文中不起作用,但在 HTTP 调用中起作用
- regex - Apache 重写动态子文件夹
- bash - df 命令在终端中有效,但在 bash 脚本中无效
- python - 如何在字符串列表中的括号之间连接字符串
- reactjs - 使用功能组件渲染后响应访问状态
- arrays - 如何使用表格分页材料-ui react js
- azure-resource-manager - 错误:凭据参数需要实现signRequest方法