刚刚做了这个:
self.imageView.backgroundColor = color1;
self.imageView.layer.masksToBounds = YES;
self.imageView.layer.borderColor = color1;
self.imageView.layer.borderWidth = 3.0;
这是问题的屏幕截图:
我可以看到图像、边框以及边框之外的图像片段……
我该如何修复它?
我在使用图层上的边框属性时遇到了类似的问题,并设法通过在顶部添加 CAShapeLayer 来解决它。
我无法告诉您它在旧设备上的表现如何,因为还没有使用许多动画等对其进行测试,但我真的怀疑它会减慢它们的速度。
下面是 Swift 中的一些代码:
imageView.backgroundColor = UIColor(red: 0.1137, green: 0.2745, blue: 0.4627, alpha: 1.0)
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = imageView.bounds.height / 2.0
let stroke:CAShapeLayer = CAShapeLayer()
let rect = imageView.bounds
let strokePath = UIBezierPath(roundedRect: rect, cornerRadius: imageView.bounds.height / 2.0)
stroke.path = strokePath.CGPath
stroke.fillColor = nil
stroke.lineWidth = 3.0
stroke.strokeColor = UIColor(red: 0.1137, green: 0.2745, blue: 0.4627, alpha: 1.0).CGColor
stroke.frame = imageView.bounds
imageView.layer.insertSublayer(stroke, atIndex: 1)
希望它也适用于你的情况
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)