这是一个UILabel Bug吗?

时间:2015-07-10 17:00:51

标签: xcode swift uilabel

我有一个简单的自定义视图,其中有一些UILabel作为子项:

class UINotificationDetail :UIView {
let title = UILabel()
let content = UILabel()
let date = UILabel()
let dismissButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton
let kMargin : CGFloat = 10
override init(frame: CGRect) {
    super.init(frame:frame)
}
convenience init(notification : UINotification){
    self.init(frame: RB.withScreen().make())
    self.backgroundColor = Config.grayColor
    self.dismissButton.frame.size = CGSizeMake(40, 40)
    self.dismissButton.backgroundColor = UIColor.clearColor()
    self.dismissButton.setImage(UIImage(named:"x_orange"), forState: UIControlState.Normal)
    self.dismissButton.tintColor = Config.orangeColor


    let fontName = self.title.font.fontName
    self.title.numberOfLines = 0
    self.title.textColor = Config.orangeColor
    self.title.text = notification.title

    self.content.numberOfLines = 0
    self.content.font = UIFont(name: fontName, size: 12)
    self.content.text = notification.description

    self.date.font = UIFont(name: fontName, size: 10)
    self.date.numberOfLines = 0
    self.date.text = notification.date

    self.addSubview(self.date)
    self.addSubview(self.title)
    self.addSubview(self.content)
    if Config.isIphone{
        self.addSubview(self.dismissButton)
    }


}
required  init(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

override  func drawRect(rect: CGRect) {
    super.drawRect(rect)
    let width = rect.size.width - 2*kMargin

    self.dismissButton.frame = RB.withParent(rect).sameAs(self.dismissButton.frame).right(kMargin).top(kMargin / 2).make()

    self.date.frame = RB.withParent(rect).sameAs(self.date.frame).top(3*kMargin).left(kMargin).make()
    self.date.sizeToFit()

    self.title.frame = RB.withParent(rect).sameAs(self.title.frame).bottomOf(self.date.frame, offset: kMargin / 2)
        .left(kMargin).width(width).make()
    self.title.sizeToFit()

    self.content.frame = RB.withParent(rect).sameAs(self.content.frame).bottomOf(self.title.frame, offset: kMargin / 2)
        .left(kMargin).width(width).make()
    self.content.sizeToFit()

}

}

UINotification从休息服务中得到异步,这个视图很流行。 一切正常,直到我决定在管理中创建一个UINotification,在描述字符串中包含一个简单的单词:“

如果单元格和View详细信息都有一个UILabel,其文本包含di“我在单元格中看到的内容:

enter image description here

详情如下:

enter image description here

如果字符串不包含“一切正常:

细胞:

enter image description here

详细说明:

enter image description here

有人遇到了同样的问题吗? 我跑: Xcode版本6.3.2(6D2105) Swift 1.2 iOS SDK 8.3

0 个答案:

没有答案