gpt4 book ai didi

ios - 将底线边框添加到 TextView - iOS

转载 作者:搜寻专家 更新时间:2023-10-30 22:09:32 25 4
gpt4 key购买 nike

将底线边框添加到 TextView 的最佳方法是什么?我已经试过了,但它似乎不起作用。它受 textview 滚动能力的影响,并且在 TextView

中间绘制线条
func addBottomBorderWithColor(color: UIColor, width: CGFloat) {
let border = CALayer()
border.backgroundColor = color.CGColor
border.frame = CGRectMake(0, self.frame.size.height - width, self.frame.size.width, width)
self.layer.addSublayer(border)
self.layer.masksToBounds = true
}

编辑:TextView 具有动态高度。

最佳答案

Swift 4 版本

func addBottomBorderWithColor() {
let border = CALayer()
border.backgroundColor = UIColor.black.cgColor
border.frame = CGRect(x: 0, y: yourTextArea.frame.height - 1, width: yourTextArea.frame.width, height: 1)
yourTextArea.layer.addSublayer(border)
self.view.layer.masksToBounds = true
}

关于ios - 将底线边框添加到 TextView - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38326249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com