appcelerator/titanium_mobile — pull request #3647 by farfromrefug (2012-12-31 14:12:11+00:00)
Title: Tc 1698

[jira ticket](https://jira.appcelerator.org/browse/TC-1698)

So it s a big one.
It s a completely new label to support html and more.
It s based on [DTCoreText](https://github.com/Cocoanetics/DTCoreText) and [TTTAttributeLabel](https://github.com/mattt/TTTAttributedLabel)

Actually for DTCoreText it s based on my [fork](https://github.com/Akylas/DTCoreText) of it as i needed to modify it

I need DTCoreText for the "html string to NSAttributeString" and i use TTTAttributeLabel as the label it self (because the one from DTCoreText wasn't good enough).

As for the integration of DTCoreText(and DTFoundation as it comes with) into Titanium, i did what i could and i am willing to modify anything necessary.

Now about the label itself it behaves even better than the original one.
To show that and mostly to test the new label i actually let the old one in as TiUILabelOld. It will allow to compare the two.

I did some heavy testing and everything seems to be working.
Only one thing is bugging me and it was already present in the old one: The label doesnt behave correctly while animating. Especially the view is animated but the label view (the subview added in TiUILabel) is not and resize immediately. You can see the behavior in the example below.

Here is the example i use to test compare
```javascript
var win = Titanium.UI.createWindow();
win.backgroundColor = 'white';

function merge_options(obj1,obj2){
var obj3 = {};
for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
return obj3;
}

var holder = Ti.UI.createView({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
layout:'vertical'
})

var args = {
top:5,
width: 200,
height: Ti.UI.SIZE,
textAlign:'center',
verticalAlign:'center',
font:{fontSize:12, fontWeight:'normal'},
shadowOffset:{x:0, y:1},
shadowColor:'#ff000000',
shadowRadius:4,
textPaddingRight:15,
textPaddingTop:5,
wordWrap:false,
borderRadius:4,
autoLink : Ti.UI.AUTOLINK_MAP_ADDRESSES|Ti.UI.AUTOLINK_PHONE_NUMBERS|Ti.UI.AUTOLINK_URLS
}
var viewOld = Titanium.UI.createLabelOld(merge_options(args, {
backgroundColor:'green',
text: "hello, world! I'm really happy to see you. And now this test needs to be longer"
}));
holder.add(viewOld);

var viewNew1 = Titanium.UI.createLabel(merge_options(args, {
backgroundColor:'green',
text: "hello 0679113383, world! http://google.com ok. now an address 2 rue edouard branly grenoble france"
}));
holder.add(viewNew1);

viewNew1.addEventListener('touchstart', function(e){
if (e.source.height === Ti.UI.SIZE)
e.source.animate({height:30, duration:500});
else
e.source.animate({height:Ti.UI.SIZE, duration:500});
});

var viewNew2 = Titanium.UI.createLabel(merge_options(args, {
backgroundColor:'green',
html: 'Nevada Hotel
Floor 1F',
}));
holder.add(viewNew2);

viewNew2.addEventListener('touchstart', function(e){
if (e.source.textAlign === 'left')
e.source.textAlign = 'center';
else if (e.source.textAlign === 'center')
e.source.textAlign = 'right';
else
e.source.textAlign = 'left';

if (e.source.verticalAlign === 'top')
e.source.verticalAlign = 'center';
else if (e.source.verticalAlign === 'center')
e.source.verticalAlign = 'bottom';
else
e.source.verticalAlign = 'top';

if (e.source.backgroundColor === 'green')
e.source.backgroundColor = 'red';
else
e.source.backgroundColor = 'green';
});

win.add(holder);
win.open();
```