문제

I've created a monochrome ticker [think stock ticker] to display information the user encounters within my app. It's a wide and narrow instance of UIScrollView whose content is filled by an instance of UILabel with the relevant text. The parent view is its own delegate and takes care of the horizontal scrolling animation. The UILabel instance is set to one line only.

I'd like for the text to be in two colors (red and black) where necessary, and possibly plain and italics again where necessary. Of course UILabel is not capable of doing this, and neither is UITextView.

The obvious thing to try is replacing the UILabel instance with an instance of UIWebView and send it an html-string to format the text. However the results are not yet quite as satisfying as with UILabel - the text has margin offsets, for instance, and it needs to be displayed on one line.

Another solution, which works but I'm not satisfied with, is to have the UIScrollView display a concatenated sequence of UILabel instances each with the appropriate font or text color.

With regard to the UIWebView solution what do you advise? For instance, how would you configure an instance of a UIWebView to visually and faithfully resemble the UILabel?

도움이 되었습니까?

해결책

check out the fancy label example at http://furbo.org/2008/10/07/fancy-uilabels/
if it helps you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top