当前位置:网站首页>SwiftUI 教程之如何在 2 秒内实现自动滚动功能
SwiftUI 教程之如何在 2 秒内实现自动滚动功能
2022-07-07 09:46:00 【知识大胖】
使用 SwiftUI 进行开发令人惊讶。它确实使得只需几行代码就可以实现一些很酷的功能。今天,我们来实现自动滚动。当您创建聊天应用程序时,此技术特别有用。我将尽可能简要地解释它。
准备你的 UI
struct AutoScrollList: View {
var body: some View {
VStack {
Button("Scroll to 100") {
}
List(1...500, id: \.self) { index in
Text("\(index)")
}
}
}
}
我用一个按钮实现了一个非常简单的列表。当用户单击按钮时,我希望我的列表(滚动视图)滚动到某个位置。我如何实现它?
包裹整个视图ScrollViewReader
struct AutoScrollList: View {
var body: some View {
ScrollViewReader { proxy in
VStack {
Button("
边栏推荐
- Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)
- STM32F1与STM32CubeIDE编程实例-315M超再生无线遥控模块驱动
- Electron adding SQLite database
- 总结了200道经典的机器学习面试题(附参考答案)
- SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
- 【神经网络】卷积神经网络CNN【含Matlab源码 1932期】
- 一起探索云服务之云数据库
- 對比學習之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
- 深度学习秋招面试题集锦(一)
- Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
猜你喜欢
科普达人丨一文弄懂什么是云计算?
Electron adding SQLite database
Unsupervised learning of visual features by contracting cluster assignments
【滤波跟踪】基于matlab捷联惯导仿真【含Matlab源码 1935期】
. Net Maui performance improvement
The Oracle message permission under the local Navicat connection liunx is insufficient
Solve the problem that vscode can only open two tabs
关于测试人生的一站式发展建议
【最短路】ACwing 1127. 香甜的黄油(堆优化的dijsktra或spfa)
[system design] index monitoring and alarm system
随机推荐
清华姚班程序员,网上征婚被骂?
STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于SPI)
STM32F1与STM32CubeIDE编程实例-315M超再生无线遥控模块驱动
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
Onedns helps college industry network security
In SQL, I want to set foreign keys. Why is this problem
在我有限的软件测试经历里,一段专职的自动化测试经验总结
Design intelligent weighing system based on Huawei cloud IOT (STM32)
Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)
What development models did you know during the interview? Just read this one
Electron adding SQLite database
大佬们有没有人遇到过 flink oracle cdc,读取一个没有更新操作的表,隔十几秒就重复读取
使用MeterSphere让你的测试工作持续高效
相机标定(1): 单目相机标定及张正友标定基本原理
Electron adding SQLite database
Cmu15445 (fall 2019) project 2 - hash table details
.NET MAUI 性能提升
正在运行的Kubernetes集群想要调整Pod的网段地址
Two week selection of tdengine community issues | phase II