#define TEXTVIEW_SET_HTML_TEXT(__textView__, __text__)\
do\
{\
if ([__textView__ respondsToSelector: NSSelectorFromString(@"setContentToHTMLString:")])\
[__textView__ performSelector: NSSelectorFromString(@"setContentToHTMLString:") withObject: __text__];\
else\
__textView__.text = __text__;\
}\
while (0)
#define TEXTVIEW_GET_HTML_TEXT(__textView__, __text__)\
do\
{\
if ([__textView__ respondsToSelector: NSSelectorFromString(@"contentAsHTMLString")])\
__text__ = [__textView__ performSelector: NSSelectorFromString(@"contentAsHTMLString") withObject: nil];\
else\
__text__ = __textView__.text;\
}\
while (0)
Usage :
UITextView * over = [[UITextView alloc] initWithFrame:CGRectMake(5, 205, 310, 150)];
[over setBackgroundColor:[UIColor clearColor]];
[over setFont:[UIFont fontWithName:@"Optima-Bold" size:12.0]];
TEXTVIEW_SET_HTML_TEXT(over,@"your html text");
[over setTextColor:[UIColor whiteColor]];
[self.view addSubview:over];