[TIMOB-19168] iOS: attributedString does not override text property like documented
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | None |
| Status | Resolved |
| Resolution | Cannot Reproduce |
| Resolution Date | 2017-07-08T22:16:56.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | iOS |
| Labels | TCSupportTriage, attributedString, label, text |
| Reporter | Fokke Zandbergen |
| Assignee | Unknown |
| Created | 2014-11-12T13:12:34.000+0000 |
| Updated | 2018-02-28T19:55:42.000+0000 |
Description
The [documentation says](http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Label-property-attributedString) a Label's
text property will be ignored if attributedString. However, the following test case shows it's not:
Test case
Remove the comments before line #7 and the label will say "Text".
var win = Titanium.UI.createWindow({
backgroundColor: '#ddd',
});
win.add(Ti.UI.createLabel({
top: 100,
// text: 'Text',
attributedString: Ti.UI.createAttributedString({
text: 'Attributed String',
attributes: [{
type: Ti.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
value: 'red',
range: [0, 10]
}]
})
}));
win.open();
The same might also be true for the value property of TextArea and TextField.
Possible fix is to manually check the attributedString property in the TiUILabel.m:
// Skip text property, when attributedString is set. if([[self proxy] valueForKey:@"attributedString"] != nil) { return; }Cannot reproduce in latest versions of the SDK, so it was probably fixed during moving from the Ti.UI.iOS to the parity Ti.UI namespace.