Is it possible for me to add text to a uiwebview and change the text and colours in this view without having separate html files? So I define whats in the html file in a switch statement? I do this at the moment using labels, but I can’t have more than one colour in a label so I need to use html, as core text looks quite complicated.
switch (counter)
{
case 0:
titleLabel.text = @"needs to be more than one colour";
break;
case 1:
titleLabel.text = @"needs to be more than one colour";
break;
and so on…
Can I in some way define whats in a html file in tags in the code in these switches rather than having seperate html files? If so how would I do this?
Cheers,
Lewis
Assuming your HTML contains a CSS class called myCssClass where you specify your colors, and a label:
You can programmatically execute javascript to set a different CSS class using code like this:
though honestly if you watch the WWDC 2012 videos on CoreText you might be less intimidated…