简体   繁体   中英

How can I have clickable links in UILabel while drawing text with a shadow?

I need to do data detection of website URL's in live chat and display them in a UILabel NOT UITextView. They need to be clickable and will open a in-app browser. We have tried Craig Hockenberry's code, three20, and making our own, all of which didn't work. We need to use UILabel to take advantage of shadows. Anyone know what to do? Help!

Craig's implementation breaks a label down into a series of clickable buttons for the hyperlinks in the text. You'll need to replace the label on the UIButtons (through subclassing or otherwise) to enable the shadowing of the text.

If you need a UILabel subclass capable of arbitrary shadowing / glowing, I provide one in the sample code for the Quartz section of my iPhone class.

UILabel can only display plain text .

If you roll your own, you can use CGContextSetShadow or CGContextSetShadowWithColor to add the shadows.

(Also check the TTShadowStyle class.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM