@@ -13,6 +13,7 @@ class CheckingViewController: ViewController<CheckingView> {
1313
1414 override func viewDidLoad( ) {
1515 super. viewDidLoad ( )
16+
1617 // 添加电话号码类型监听
1718 container. label. attributed. observe ( [ . phoneNumber] , highlights: [ . foreground( #colorLiteral( red: 0.4745098054 , green: 0.8392156959 , blue: 0.9764705896 , alpha: 1 ) ) ] ) { ( result) in
1819 print ( result)
@@ -35,27 +36,50 @@ class CheckingViewController: ViewController<CheckingView> {
3536 }
3637
3738 do {
38- var string : AttributedString = """
39- 我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是18611401994@163.com,现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \( " 点击联系我 " , . action( clicked) )
40- """
41- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.9529411793 , green: 0.6862745285 , blue: 0.1333333403 , alpha: 1 ) ) , . font( . systemFont( ofSize: 20 , weight: . medium) ) ] , checkings: [ . phoneNumber] )
42- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.1764705926 , green: 0.4980392158 , blue: 0.7568627596 , alpha: 1 ) ) , . font( . systemFont( ofSize: 20 , weight: . medium) ) ] , checkings: [ . link] )
43- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.1764705926 , green: 0.01176470611 , blue: 0.5607843399 , alpha: 1 ) ) , . font( . systemFont( ofSize: 20 , weight: . medium) ) ] , checkings: [ . date] )
44- string. add ( attributes: [ . font( . systemFont( ofSize: 20 , weight: . medium) ) ] , checkings: [ . action] )
45- container. label. attributed. text = string
39+
40+ // 目前的问题是, 如果内容显示全 是OK的, 如果显示不全 就会有问题, 比如numberOfLines = x 或者 height较小.
41+
42+ let label = UILabel ( frame: . init( x: 15 , y: 80 , width: 414 - 30 , height: 750 ) )
43+ label. backgroundColor = . white
44+ view. addSubview ( label)
45+ label. attributed. observe ( . regex( " a " ) ) { ( result) in
46+ // 随便添加个监听 以便触发点击事件 显示DebugView
47+ }
48+ // label.font = UIFont(name: "Georgia", size: 20)!
49+ label. font = . systemFont( ofSize: 20 )
50+ label. numberOfLines = 0 // 限制行数后会存在显示不一致的问题 目前无法解决
51+ label. lineBreakMode = . byTruncatingTail
52+
53+ let string : AttributedString = . init(
54+ """
55+ \( " iCloud 🤗能将你的 GarageBand 创作进度在你所有的 iOS 设备间保持更新🤗。 " , . font( UIFont ( name: " Georgia-Italic " , size: 30 ) !) , . paragraph( . lineSpacing( 10 ) ) ) \n 它还可以让你在 iPad、iPhone 或 iPod \( . image( #imageLiteral( resourceName: " huaji " ) , . custom( . center, size: . init( width: 133 , height: 133 ) ) ) ) touch 上开始勾勒(灬ꈍ ꈍ灬)一首歌的灵感,然后用 iCloud Drive 将音轨导入 Mac 做进一步创作,再将完成的作品共享到你的任何设备。你还可以导入 Logic Pro 项目的便携版本,接着创作其他音轨。 \n \n 当你重新在 \( " Logic Pro " , . font( UIFont ( name: " HelveticaNeue " , size: 30 ) !) ) 打开该项目时,所😺有原始音轨以及在 GarageBand 中另外添加的音轨,都将🥔同时显示出来。Hello world \( . image( #imageLiteral( resourceName: " swift-icon " ) , . proposed( ) ) )
56+ """ , . paragraph( . firstLineHeadIndent( 10 ) , . paragraphSpacing( 5 ) )
57+ )
58+ label. attributed. text = string
4659 }
4760
48- do {
49- var string : AttributedString = """
50- My name is Li Xiang, my mobile phone number is 18611401994, my email address is 18611401994@163.com, I live in No.10 Xitucheng Road, Haidian District, Beijing, China, and it is now 20:30 on June 28, 2020. My GitHub homepage is https://github.com/lixiang1994. Welcome to star me! \( " Contact me " , . action( clicked) )
51- """
52- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.9529411793 , green: 0.6862745285 , blue: 0.1333333403 , alpha: 1 ) ) ] , checkings: [ . address] )
53- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.4666666687 , green: 0.7647058964 , blue: 0.2666666806 , alpha: 1 ) ) ] , checkings: [ . link, . phoneNumber] )
54- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.1764705926 , green: 0.01176470611 , blue: 0.5607843399 , alpha: 1 ) ) ] , checkings: [ . date] )
55- string. add ( attributes: [ . foreground( #colorLiteral( red: 0.9098039269 , green: 0.4784313738 , blue: 0.6431372762 , alpha: 1 ) ) ] , checkings: [ . regex( " Li Xiang " ) ] )
56- string. add ( attributes: [ . font( . systemFont( ofSize: 16 , weight: . medium) ) ] , checkings: [ . action] )
57- container. textView. attributed. text = string
58- }
61+ // do {
62+ // var string: AttributedString = """
63+ // 我的名字叫李响,我的手机号码是18611401994,我的电子邮件地址是18611401994@163.com,现在是2020/06/28 20:30。我的GitHub主页是https://github.com/lixiang1994。欢迎来Star! \("点击联系我", .action(clicked))
64+ // """
65+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1)), .font(.systemFont(ofSize: 20, weight: .medium))], checkings: [.phoneNumber])
66+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.1764705926, green: 0.4980392158, blue: 0.7568627596, alpha: 1)), .font(.systemFont(ofSize: 20, weight: .medium))], checkings: [.link])
67+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.1764705926, green: 0.01176470611, blue: 0.5607843399, alpha: 1)), .font(.systemFont(ofSize: 20, weight: .medium))], checkings: [.date])
68+ // string.add(attributes: [.font(.systemFont(ofSize: 20, weight: .medium))], checkings: [.action])
69+ // container.label.attributed.text = string
70+ // }
71+
72+ // do {
73+ // var string: AttributedString = """
74+ // My name is Li Xiang, my mobile phone number is 18611401994, my email address is 18611401994@163.com, I live in No.10 Xitucheng Road, Haidian District, Beijing, China, and it is now 20:30 on June 28, 2020. My GitHub homepage is https://github.com/lixiang1994. Welcome to star me! \("Contact me", .action(clicked))
75+ // """
76+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1))], checkings: [.address])
77+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.4666666687, green: 0.7647058964, blue: 0.2666666806, alpha: 1))], checkings: [.link, .phoneNumber])
78+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.1764705926, green: 0.01176470611, blue: 0.5607843399, alpha: 1))], checkings: [.date])
79+ // string.add(attributes: [.foreground(#colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1))], checkings: [.regex("Li Xiang")])
80+ // string.add(attributes: [.font(.systemFont(ofSize: 16, weight: .medium))], checkings: [.action])
81+ // container.textView.attributed.text = string
82+ // }
5983
6084 container. tintAdjustmentMode = . normal
6185 }
0 commit comments