ios - 如何将我的文本字段设为线而不是框?

标签 ios swift3 uitextfield

这是文本字段的理想设计:

This is the desired design for the Textfields

这是我设计的:

This is what I have designed

我是否必须导入一些库或安装一些 pod?有程序化的方法吗?

最佳答案

下面是代码。

@IBOutlet weak var fullName: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()

    let bottomBorder = CALayer()
    bottomBorder.frame = CGRect(x: 0, y: fullName.frame.size.height-1, width: fullName.frame.size.width, height: 1.0)
    bottomBorder.backgroundColor = UIColor.white.cgColor
    fullName.layer.addSublayer(bottomBorder)
}

输出:

enter image description here

关于ios - 如何将我的文本字段设为线而不是框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442506/

相关文章:

iphone - iOS 在线程中获取 UITextField 文本,显示 '_WebThreadLockFromAnyThread'

ios - UITextFieldDelegate 和整行删除

ios - 声音仅在 iOS 中首次使用 AVAudioEngine 播放

ios - 无法生成调试符号

ios - 是否可以通过泛型类传递属性?

ios - 执行 segue 并作为发件人发送元组

iphone - iPhone SDK中防止光标移到键盘后面的最简单方法?

ios - UITextView : Tapping a universal deep link that should lead to the SAME app, 在 Safari 中打开回退 URL

ios - 来自 google api 的所有国家和美国各州

ios - map 上特定位置的用户当前位置