Ant*_*vez 0 border uiimage swift
我试图在 Swift 中寻找“双边框”技巧来做到这一点。我有一种感觉,这可能就像 UIImage 中的“双边框”。
如果您知道代码,请告诉我。:)
小智 5
您需要将 borderColor(black) 和cornerRadius 添加到UIImageView 的默认图层中。除此之外,您还必须在 UIImageView 中添加另一个子图层,其 borderColor 为灰色。
imageView.layer.borderWidth = 4.0
imageView.layer.borderColor = UIColor.gray.cgColor
imageView.layer.cornerRadius = imageView.frame.width / 2
let borderLayer = CALayer()
borderLayer.frame = imageView.bounds
borderLayer.borderColor = UIColor.black.cgColor
borderLayer.borderWidth = 14.0
borderLayer.cornerRadius = borderLayer.frame.width / 2
imageView.layer.insertSublayer(borderLayer, above: imageView.layer)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1144 次 |
最近记录: |