ios - CALayer 不显示 iOS8

标签 ios swift ios8 calayer

在我的应用程序的联系表单中,文本输入字段的框底部有一条白线。

let border = CALayer()
border.frame = CGRect(x: 0, y: textInput.frame.height, width: textInput.frame.width, height: 3)
border.borderColor = UIColor.white.cgColor
border.borderWidth = 3
textInput.layer.addSublayer(border)

所需的边框在 iOS10 上显示正常,但在 iOS8 上测试时却不显示。

iOS 8 是否有一些我不知道的利基市场?

最佳答案

您的 Y 点是文本输入的高度,使其为 0 或小于高度的值

let border = CALayer()

border.frame = CGRect(x: 0, y: textInput.frame.height - 3, width: textInput.frame.width, height: 3)

border.borderColor = UIColor.white.cgColor

border.borderWidth = 3

textInput.layer.addSublayer(border)

关于ios - CALayer 不显示 iOS8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46465678/

相关文章:

xcode - Xcode 中的约束控件变灰(将工具栏固定到底部)

xcode - CFString 不符合 Hashable 协议(protocol)?

ios - 将对象传递给选项卡应用程序中的另一个 View Controller

ios - UISearchController 在索引路径上崩溃

ios - Google 日历 API 删除/更新重复事件在 URLSession 上返回 412

json - 如何使用 Swift Decodable 协议(protocol)解析 JSON API 结构中的几个硬编码键?

ios - 如何使用 Alamofire 和 session 管理器附加 MultipartFormData 以及其他发布参数?

iphone - 在 iphone 上使用正则表达式捕获括号

ios - iOS Swift 中的下标选项

ios - 滚动时隐藏状态栏