Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19168] iOS: attributedString does not override text property like documented

GitHub Issuen/a
TypeBug
PriorityNone
StatusResolved
ResolutionCannot Reproduce
Resolution Date2017-07-08T22:16:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsTCSupportTriage, attributedString, label, text
ReporterFokke Zandbergen
AssigneeUnknown
Created2014-11-12T13:12:34.000+0000
Updated2018-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.

Comments

  1. Hans Knöchel 2015-07-05

    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;
       }
       
  2. Hans Knöchel 2017-07-08

    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.

JSON Source