当前位置:网站首页>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("边栏推荐
- 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?
- Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
- Flet教程之 19 VerticalDivider 分隔符组件 基础入门(教程含源码)
- 聊聊SOC启动(十一) 内核初始化
- 'module 'object is not callable error
- Audit migration
- STM32F1与STM32CubeIDE编程实例-315M超再生无线遥控模块驱动
- Briefly introduce closures and some application scenarios
- 什么是高内聚、低耦合?
- QT | multiple windows share a prompt box class
猜你喜欢

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

【滤波跟踪】基于matlab扩展卡尔曼滤波EKF和无迹卡尔曼滤波UKF比较【含Matlab源码 1933期】

In my limited software testing experience, a full-time summary of automation testing experience

The road to success in R & D efficiency of 1000 person Internet companies

对比学习之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments

Half of the people don't know the difference between for and foreach???

相机标定(1): 单目相机标定及张正友标定基本原理

【纹理特征提取】基于matlab局部二值模式LBP图像纹理特征提取【含Matlab源码 1931期】

Test the foundation of development, and teach you to prepare for a fully functional web platform environment

一度辍学的数学差生,获得今年菲尔兹奖
随机推荐
Verilog design responder [with source code]
The database synchronization tool dbsync adds support for mongodb and es
Android interview knowledge points
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
VIM command mode and input mode switching
Suggestions on one-stop development of testing life
Blog moved to Zhihu
相机标定(2): 单目相机标定总结
核舟记(一):当“男妈妈”走进现实,生物科技革命能解放女性吗?
'module 'object is not callable error
The road to success in R & D efficiency of 1000 person Internet companies
Nuclear boat (I): when "male mothers" come into reality, can the biotechnology revolution liberate women?
SwiftUI 4 新功能之掌握 WeatherKit 和 Swift Charts
使用MeterSphere让你的测试工作持续高效
自动化测试框架
聊聊SOC启动(七) uboot启动流程三
Technology sharing | packet capturing analysis TCP protocol
【时间格式工具函数的封装】
Excel公式知多少?
How to add aplayer music player in blog