iOS UIScrollView的一个特性

1如果UIScrollView 的contentSize.height >

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom

, 则scrollView就可以滚动,否则无法滚动

并且最大的滚动范围就是 contentSize.height - (

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom

这里说的是自然滚动,就是在用户松手的情况下

能滚动的最大范围

并且,我们通过代码 uiscrollView setContentOffset:animated:YES

或者 uiscrollView setContentOffset:cgpointmake设置的

都只能是自动滚动能达到的位置,即 在contentSize.height - (

scrollView.bounds.size.height - scrollView.contentInset.top - scrollView.contentInset.bottom)之内,否则即使设置了,也会因为

contentSize不够而导致失败

2

两个滚动方法的不同

复制代码
[uiscrollView setContentOffset:animated:YES]

会出发scrollView 的 scrollViewDidScroll代理方法

复制代码
[uiView animatedwithduration:0.2 animated:^{
[uiscrollView setContentOffset:animated:NO]
}];

不会触发scrollViewDidScroll代理方法

相关推荐
CocoaKier12 小时前
神技分享:App加锁,App隐藏?苹果官方自带,只需要一个长按
ios·apple
FungLeo14 小时前
Swift macOS 游戏开发实战|空当接龙 11|使用 Swift Actor 实现自动存档与坏档保护
macos·swift·数据持久化·actor·swift并发
sean90818 小时前
macOS Outlook(或者是Office系列?) App 打开时自动启动 Microsoft Autoupdate 处理
microsoft·macos·outlook·自动更新
FungLeo18 小时前
Swift macOS 游戏开发实战|空当接龙 09|SwiftUI 与 AppKit 动画,如何分离显示与游戏状态
macos·swiftui·动画·swift·appkit
FungLeo19 小时前
Swift macOS 游戏开发实战|空当接龙 13|SwiftUI 与 AppKit 应用的多语言切换与 RTL 布局
macos·国际化·swiftui·swift·rtl
传奇开心果编程21 小时前
【六大移动UI框架比较学与练】第5课:交互与导航——事件处理、手势与页面路由实战对照
android·flutter·react native·ios·swiftui·移动开发·android jetpack
AirDroid_cn1 天前
下棋也有“光影魔术”:macOS Sequoia国际象棋棋盘随环境光自动变质感
macos
Geek-Chow1 天前
01 · 为什么要在 iOS 上用 Redux
ios
传奇开心果编程2 天前
【六大移动UI框架比较学与练】第3课:文本、图片、布局核心组件实战对照
android·flutter·react native·ios·swiftui·移动开发·android jetpack
FungLeo2 天前
Swift macOS 游戏开发实战|空当接龙 07|使用 Swift 计算稳定牌桌布局与命中区域
macos·swift·游戏开发·界面布局·命中检测