当前位置:网站首页>SwiftUI 组件之如何实现电话号码掩码隐藏部分的文本字段TextField(教程含源码)
SwiftUI 组件之如何实现电话号码掩码隐藏部分的文本字段TextField(教程含源码)
2022-07-28 17:07:00 【知识大胖】
SwiftUI 没有手机遮罩工具,需要使用 UIKit。
在本文中,我们将研究:使用 UIKit 编写的注册到 SwiftUI 项目时使用手机掩码。

- 在 SwiftUI 上创建视图
import SwiftUI
struct NumberPhoneMaskView: View {
let maskPhone = "+X-XXX-XXX-XX-XX"
@State var text = ""
var body: some View {
VStack {
let textChangedBinding = Binding<String>(
get: {
FilterNumberPhone.format(with: self.maskPhone, phone: self.text)},
set: { self.text = $0
})
TextFieldContainer("+1", text: textChangedBinding)
}.padding()
}
}
struct NumberPhoneMaskView_Previews: PreviewProvider {
static var previews: some View {
NumberPhoneMaskView()
}
}
- 创建一个TextFieldContainer结构&#x
边栏推荐
- 湖上建仓全解析:如何打造湖仓一体数据平台 | DEEPNOVA技术荟系列公开课第四期
- NPM cannot recognize the "NPM" item as the name of a cmdlet, function, script file, or runnable program. Please check the spelling of the name. If the path is included, make sure the path is correct,
- SwiftUI Swift 之正向地理编码与反向地理编码(教程含源码)
- 视频融合云服务EasyCVR平台白名单功能如何使用?
- JVM four reference types
- 2022.7.26 构造函数,面试:new的作用、深拷贝和浅拷贝
- UE5 GAS 学习笔记 1.3属性Attribute
- What skills do you need to master when learning software testing zero foundation?
- LVS manual
- LeetCode_96_不同的二叉搜索树
猜你喜欢

LeetCode_63_不同路径Ⅱ

面试官:ThreadLocal使用场景有哪些?内存泄露问题如何避免?

行业落地呈现新进展 | 2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛圆满召开

Interviewer: what are the usage scenarios of ThreadLocal? How to avoid memory leakage?

Go concurrency one

2022年中国企业服务产业市场行情

三分钟了解快来新媒体
![[GXYCTF2019]StrongestMind](/img/f4/61932548e0c7dd60d790d31fb5b96b.png)
[GXYCTF2019]StrongestMind

The switching language of unity causes an error: system FormatException:String was not recognized as a valid DateTime.

MYSQL入门与进阶(三)
随机推荐
EasyCVR接入设备后播放视频出现卡顿现象的原因分析及解决
Ue5 gas learning notes 1.5 gameplay effects game effects
[actual combat] realize page distortion correction with OpenCV
Kotlin:Sealed class密封类详解
1.3、链表
MYSQL入门与进阶(二)
@Autowired与@Resource区别
零知识证明:具有DDH假设的 ZKP
UE5 GAS 学习笔记 1.4属性集
行业落地呈现新进展 | 2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛圆满召开
三分钟了解快来新媒体
Error 2003 (HY000) can't connect to MySQL server on 'localhost3306' (10061) solution
redis持久化之RDB和AOF的区别
Ue5 gas learning notes 1.9 skill system global classes (abilitysystemglobals)
Introduction and advanced level of MySQL (10)
Meta Q2 earnings: revenue fell for the first time, and metaverse will compete with apple
LeetCode_96_不同的二叉搜索树
Gateway入门
Record your interview experience in Xiamen for two years -- Conclusion
kotlin:Nothing