当前位置:网站首页>Swiftui 4 new features complete toggle and mixed toggle multiple binding components
Swiftui 4 new features complete toggle and mixed toggle multiple binding components
2022-07-01 20:01:00 【Knowledge fatness】
from SwiftUI 4 Start ,Toggle Views can now be bound to multiple values . Now we can use the following overload initializer to create switches for the set of values :
init(isOn:label:)
- isOn: Is a binding collection , Used to determine whether the switch is on 、 Close or mix .
- Label: It is a view that describes the purpose of switching .
There are two additional overload initializations :
init(_:isOn:)
The first parameter is titleKey( The key used to describe the switching localization title for switching purposes ), The second parameter is isOn( Make sure the switch is on 、 Closed or mixed binding collection )
init(_:isOn:)
The initializer above is similar to the previous one , It just needs a string instead of titleKeyinit .title
Multiple bindings
As mentioned earlier ,toggle Multi value binding is now supported , So let's look at an example . We will show from HomeSecurity The data structure of the use case begins .
struct HomeSecurity: Hashable, Identifiable {
var id = UUID()
var armed: Bool
var name: String
}
Let's add an extension to this structure and add some sample data to use :
extension HomeSecurity {
static var exampleData: [HomeSecurity] = [
.init(armed: false, name: "Garage Door"),
.init(armed: true, name: "Front Door"),
边栏推荐
- servlet知识点
- 【多线程】 实现单例模式 ( 饿汉、懒汉 ) 实现线程安全的单例模式 (双重效验锁)
-
- SQL 入门计划-1-选择
- Set object value changes null value object
- uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理
- 毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
- Sum the amount
- JS ternary expression complex condition judgment
- Using win7 vulnerability to crack the system login password
猜你喜欢

Flask 常用组件

Hls4ml entry method

渗透工具-TrustedSec 公司的渗透测试框架 (PTF)

What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond

fastDFS入门

A quietly rising domestic software, low-key and powerful!
![[AI server setup] CUDA environment](/img/ca/2acfc42ea3ba24934a89472a8632f6.png)
[AI server setup] CUDA environment

How to use console Log print text?

独家消息:阿里云悄然推出RPA云电脑,已与多家RPA厂商开放合作

math_利用微分算近似值
随机推荐
PowerDesigner design name and comment replacement
一文读懂C语言中的结构体
今日群里分享的面试题
Linux下安装Redis,并配置环境
Redis installation and startup in Windows environment (background startup)
运动捕捉系统原理
How to turn off the boot auto start software in win11
Win11快捷键切换输入法无反应怎么办?快捷键切换输入法没有反应
再回顾集合容器
[Blue Bridge Cup web] analysis of the real topic of the 13th Blue Bridge Cup web university group match in 2022
MYSLQ十种锁,一篇文章带你全解析
2022/6/8-2022/6/12
Battery simulation of gazebo robot
Sum the amount
Is Dao safe? Build finance encountered a malicious governance takeover and was looted!
Flask 常用组件
使用 Kibana Timelion 进行时间序列分析
February 15, 2022: sweeping robot. There is a floor sweeping robot in the room (represented by a grid). Each grid in the grid has two possibilities: empty and obstacles. The sweeping robot provides fo
How can a programmer grow rapidly
Detailed configuration of network security "Splunk" in national vocational college skills competition