当前位置:网站首页>Swiftui tutorial how to realize automatic scrolling function in 2 seconds
Swiftui tutorial how to realize automatic scrolling function in 2 seconds
2022-07-07 11:45:00 【Knowledge fatness】
Use SwiftUI It's amazing to develop . It does make it possible to implement some cool functions in just a few lines of code . today , Let's realize automatic scrolling . When you create a chat application , This technique is particularly useful . I will explain it as briefly as possible .
Prepare your UI
struct AutoScrollList: View {
var body: some View {
VStack {
Button("Scroll to 100") {
}
List(1...500, id: \.self) { index in
Text("\(index)")
}
}
}
}
I implemented a very simple list with a button . When the user clicks the button , I want my list ( Scroll view ) Scroll to a position . How do I achieve it ?
Wrap the entire view ScrollViewReader
struct AutoScrollList: View {
var body: some View {
ScrollViewReader { proxy in
VStack {
Button("
边栏推荐
- QT | multiple windows share a prompt box class
- 一起探索云服务之云数据库
- Various uses of vim are very practical. I learned and summarized them in my work
- VIM command mode and input mode switching
- 简单介绍一下闭包及它的一些应用场景
- 【滤波跟踪】基于matlab捷联惯导仿真【含Matlab源码 1935期】
- SwiftUI Swift 内功之 Swift 中使用不透明类型的 5 个技巧
- 测试优惠券要怎么写测试用例?
- 正在运行的Kubernetes集群想要调整Pod的网段地址
- [encapsulation of time format tool functions]
猜你喜欢
请查收.NET MAUI 的最新学习资源
【神经网络】卷积神经网络CNN【含Matlab源码 1932期】
MySQL安装常见报错处理大全
总结了200道经典的机器学习面试题(附参考答案)
聊聊SOC启动(六)uboot启动流程二
Design intelligent weighing system based on Huawei cloud IOT (STM32)
Unsupervised learning of visual features by contracting cluster assignments
Reasons for the failure of web side automation test
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
千人规模互联网公司研发效能成功之路
随机推荐
sink 消费 到 MySQL, 数据库表里面已经设置了 自增主键, flink 里面,如何 操作?
关于测试人生的一站式发展建议
【系统设计】指标监控和告警系统
Enclosed please find. Net Maui's latest learning resources
Excel公式知多少?
聊聊SOC启动(六)uboot启动流程二
测试开发基础,教你做一个完整功能的Web平台之环境准备
Tsinghua Yaoban programmers, online marriage was scolded?
【纹理特征提取】基于matlab局部二值模式LBP图像纹理特征提取【含Matlab源码 1931期】
MIF file format record
Android 面试知识点
R language uses the quantile function to calculate the quantile of the score value (20%, 40%, 60%, 80%), uses the logical operator to encode the corresponding quantile interval (quantile) into the cla
STM32 entry development write DS18B20 temperature sensor driver (read ambient temperature, support cascade)
Common SQL statement collation: MySQL
自动化测试框架
相机标定(2): 单目相机标定总结
深度学习秋招面试题集锦(一)
【问道】编译原理
Design intelligent weighing system based on Huawei cloud IOT (STM32)
技术分享 | 抓包分析 TCP 协议