当前位置:网站首页>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("边栏推荐
- 對比學習之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
- 禁锢自己的因素,原来有这么多
- 技术分享 | 抓包分析 TCP 协议
- Audit migration
- Qt|多个窗口共有一个提示框类
- Reasons for the failure of web side automation test
- 简单介绍一下闭包及它的一些应用场景
- 使用引用
- Some opinions and code implementation of Siou loss: more powerful learning for bounding box regression zhora gevorgyan
- 科普达人丨一文弄懂什么是云计算?
猜你喜欢

Design intelligent weighing system based on Huawei cloud IOT (STM32)

禁锢自己的因素,原来有这么多

STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于SPI)

请查收.NET MAUI 的最新学习资源

关于测试人生的一站式发展建议

electron添加SQLite数据库

如何在博客中添加Aplayer音乐播放器

Talk about SOC startup (IX) adding a new board to uboot

竟然有一半的人不知道 for 与 foreach 的区别???

Leetcode - interview question 17.24 maximum submatrix
随机推荐
科普达人丨一文弄懂什么是云计算?
Internet Protocol
Various uses of vim are very practical. I learned and summarized them in my work
Apprentissage comparatif non supervisé des caractéristiques visuelles par les assignations de groupes de contrôle
自动化测试框架
Android interview knowledge points
R语言使用quantile函数计算评分值的分位数(20%、40%、60%、80%)、使用逻辑操作符将对应的分位区间(quantile)编码为分类值生成新的字段、strsplit函数将学生的名和姓拆分
深度学习秋招面试题集锦(一)
electron添加SQLite数据库
使用引用
自律,提升自制力原来也有方法
聊聊SOC启动(十) 内核启动先导知识
Android 面试知识点
electron 添加 SQLite 数据库
Flet教程之 17 Card卡片组件 基础入门(教程含源码)
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
About the application of writing shell script JSON in JMeter
The Oracle message permission under the local Navicat connection liunx is insufficient
问下flinkcdc2.2.0的版本,支持并发,这个并发是指多并行度吗,现在发现,mysqlcdc全
Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)