ios - 应用自定义遮罩时 UITextfield 的断角
问题描述
我正在尝试创建一个左角四舍五入的文本字段。为此,我使用以下代码来应用屏蔽。现在文本字段的角被修剪掉了。知道为什么吗?
let shape = CAShapeLayer()
shape.bounds = textfieldContainerView.frame
shape.position = textfieldContainerView.center
shape.path = UIBezierPath(roundedRect: textfieldContainerView.bounds,
byRoundingCorners: [.topLeft, .bottomLeft],
cornerRadii: CGSize(width: 5, height: 5)).cgPath
textfieldContainerView.layer.mask = shape
textfieldContainerView.layer.borderColor = ColorKit.smoke.cgColor
textfieldContainerView.layer.borderWidth = 2.0
这是它的样子(注意左边的破角)。
解决方案
这适用于较低的半径和高度值,例如 4。此外,折角高度随着半径/高度值的增加而继续增加
推荐阅读
- c# - 如何修复 CSOM 错误:位置 X 的数据类型与预期的不同?
- webpack - 为什么我的 Webpack-cleanup-plugin 会删除我的排除文件?
- reactjs - 反应:按钮不起作用/无法执行状态更新
- python - Python——函数装饰器导致函数被调用两次
- javascript - 按大于 date.now 的日期过滤对象数组
- r - R:当数据帧包含字符串和数字时如何使用writexl
- python - 添加新的 QgsFeature 时,QgsVectorLayer 的属性表不会更新
- angular - Mat-pagination 不适用于 Angular 8
- php - 如何使用 C 程序中的数据动态更新浏览器
- python - Mockito 期望()不抛出异常