ios - swift 。 UIBezierPath 边框颜色

标签 ios swift uitextfield uibezierpath

我试图设置 UItextField 的右上角和左下角半径,但得到半透明的角。下图会让我的问题更清晰

enter image description here

尝试设置描边颜色和边框颜色,但没有成功。

let c = UIColor.orangeColor()
let path = UIBezierPath(roundedRect:field_name.bounds, byRoundingCorners:[UIRectCorner.TopRight, .BottomLeft], cornerRadii: CGSizeMake(20, 20))
let maskLayer = CAShapeLayer()
maskLayer.path = path.CGPath
maskLayer.fillColor = c.CGColor
field_name.layer.mask = maskLayer
field_name.layer.masksToBounds = true

如果有人帮助我编写代码,我将非常感激。

最佳答案

你可以使用这样的东西

textField.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMaxYCorner]
textField.layer.borderWidth = 1.0
textField.layer.borderColor = YourColor.cgColor

关于ios - swift 。 UIBezierPath 边框颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35673053/

相关文章:

ios - SpriteKit 无法加载以前使用过的资源

ios - 以编程方式在 iPhone 应用程序上显示键盘

ios - 垂直对齐添加为文本字段右 View 的 UIImageView 与 skyfloatinglabeltextfield 的文本

ios - Swift:无法删除具有基于条件的字符限制的文本字段中的字符

ios - BecomeFirstResponder 和多个 UITextField 焦点

ios - jenkins build of unity 出现错误

ios - "icon dimensions (60 * 60) don' t 满足大小要求”将我的应用程序提交到应用程序商店

ios - UICollectionView 显示隐藏动画问题

ios - 从 future 日期查找今天的日子

ios - 在 Swift3 中缓存自定义对象数组