cbpowell / MarqueeLabel

A drop-in replacement for UILabel, which automatically adds a scrolling marquee effect when the label's text does not fit inside the specified frame
MIT License
4.22k stars 564 forks source link

attributedString didn't show for some special charactor #147

Closed CK11FOR333 closed 8 years ago

CK11FOR333 commented 8 years ago

When I type the string "【五原素系列】", all the character are not shown.

It would be great to update this.

cbpowell commented 8 years ago

Is this an attributed string or just a regular string with special characters? I can copy/paste what you included in your issue, but I don't get any of the attributes.

Just pasting the text into the demo project appears to work:

screen shot 2016-07-09 at 4 21 02 pm

Would you be able to provide the code you're using to set up the label?

CK11FOR333 commented 8 years ago

I updated pods from v2.7.6 to 2.7.8 and it looks fine =0= I don't know what happened Maybe it's Xcode's bug at that moment.

By the way, here is my code:

    labelNameBig.frame.size = CGSize.init(width: 210, height: 50)
    labelNameBig.marqueeType = MarqueeType.MLContinuous
    labelNameBig.rate = 30
    labelNameBig.center = navigationView.center
    self.view.addSubview(labelNameBig)

        let attributedString = NSMutableAttributedString(string:strName)
        attributedString.addAttribute(NSForegroundColorAttributeName, value: UIColor(red: 255/255, green: 102/255, blue: 102/255, alpha: 1), range: NSMakeRange(0, attributedString.length))
        attributedString.addAttribute(NSFontAttributeName, value: UIFont(name: "Gill Sans", size: 17)!, range: NSMakeRange(0, attributedString.length))
        labelNameBig.attributedText = attributedString
        labelNameBig.textAlignment = .Center
        labelNameBig.marqueeType = .MLContinuous
        labelNameBig.scrollDuration = 15.0
        labelNameBig.fadeLength = 10.0
        labelNameBig.trailingBuffer = 30.0
cbpowell commented 8 years ago

Awesome! Maybe you were seeing a similar bug to the issue reported in #146, and the updates fixed it.