好吧,我从来没有经历过这个,但不知道如何让它消失:我已经以编程方式创建了几个具有特定背景颜色的UILabel。然而,在某些情况下,在上边框和右边框上,可以看到一条奇怪的深色线条(见第2行标签):
我不知道造成这种情况的原因。 以下是我制作它们的方法:
for i in 0...featureLabels.count-1
{
featureLabels[i] = RSSLinkLabel()
featureLabels[i]?.frame = CGRect(x: 0, y: 0, width: (overallWidth-(imgSpace))/3, height: ((overallWidth-(imgSpace))/3)/contentRatios[2])
featureLabels[i]?.text = "Hello label \(i)"
featureLabels[i]?.backgroundColor = UIColor(hexString: secondColorStr)
featureLabels[i]?.textAlignment = .left
featureLabels[i]?.font = iphoneFont
var pt = CGPoint()
switch i {
case 0:
pt = CGPoint(x: sideDiff + ((featureLabels[i]?.bounds.width)!/2), y: subContView2.bounds.height - ((featureLabels[i]?.bounds.height)!/2))
case 1:
pt = CGPoint(x: subContView2.bounds.width/2, y: subContView2.bounds.height - ((featureLabels[i]?.bounds.height)!/2))
case 2:
pt = CGPoint(x: sideDiff + (overallWidth - ((featureLabels[i]?.bounds.width)!/2)), y: subContView2.bounds.height - ((featureLabels[i]?.bounds.height)!/2))
default:
break
}
featureLabels[i]?.center = pt
subContView2.addSubview(featureLabels[i]!)
}
它们是我在此处定义的自定义标签:
import UIKit
class RSSLinkLabel: UILabel {
var id = String()
override init (frame : CGRect) {
super.init(frame : frame)
}
func customInit()
{
self.text = txtSources[id]
}
required public init(coder aDecoder: NSCoder) {
fatalError("This class does not support NSCoding")
}
convenience init () {
self.init(frame:CGRect.zero)
}
override public func layoutSubviews() {
customInit()
}
}
我尝试过做featureLabels[i]?.layer.borderColor = UIColor.clear.cgColor
但没有任何反应。
如何让这个大纲消失?