【问题标题】:how to change border color of text field in swift如何快速更改文本字段的边框颜色
【发布时间】:2022-11-04 14:37:26
【问题描述】:

我正在尝试更改文本标签的边框颜色,但在 Main(base) 中找不到任何更改它的选项,而我在 viewController 中使用的代码是:

`

              import UIKit

              class ViewController: UIViewController {

               @IBOutlet weak var textsa: UITextField!
               override func viewDidLoad() {
               super.viewDidLoad()
               textsa.layer.backgroundColor = CGColor(red: 23, green: 23, blue: 23, alpha: 12.3)
           } 


       }

`

【问题讨论】:

    标签: swift swiftui border textlabel


    【解决方案1】:

    您必须为文本字段图层设置边框颜色和边框宽度。

            textsa?.layer.borderColor = UIColor.red.cgColor
            textsa?.layer.borderWidth = 2.0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-31
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-14
      • 2021-11-20
      • 1970-01-01
      相关资源
      最近更新 更多