{ "id": "160053", "key": "TIMOB-23324", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "11", "description": "Is not a bug in our product", "name": "Not Our Bug" }, "resolutiondate": "2016-05-12T22:26:08.000+0000", "created": "2016-05-05T12:38:11.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "parity" ], "versions": [ { "id": "17993", "description": "Release 5.2.2", "name": "Release 5.2.2", "archived": false, "released": true, "releaseDate": "2016-04-05" } ], "issuelinks": [], "assignee": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-05-31T22:25:39.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "When TextArea or TextField has a \"font\" property, it should work as default font. \r\nBut TextArea or TextField has a \"font\" and \"attributedString\" property, TextArea on iOS works differently.\r\n\r\nExpected result is a android screen shoot\r\n!https://media.giphy.com/media/l396JakyRYcHWoq8E/giphy.gif!\r\n{code}\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n TextField with attributedString in tss\r\n \r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\n{code}\r\n$.index.open();\r\n\r\n$.ta.value = 'TextArea with attributedString in JS';\r\n$.tf.value = 'TextField with attributedString in JS';\r\nvar attr = Titanium.UI.createAttributedString({\r\n text: $.ta.value,\r\n attributes: [\r\n {\r\n type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,\r\n value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,\r\n range: [0, 2]\r\n }\r\n ]\r\n});\r\n\r\n$.ta.attributedString = attr;\r\n$.tf.attributedString = attr;\r\n{code}\r\n\r\n{code}\r\n\"Window\":{\r\n backgroundColor: \"white\",\r\n layout: \"vertical\"\r\n}\r\n\"TextArea\":{\r\n borderColor: \"gray\",\r\n borderWidth: 1,\r\n width: Ti.UI.FILL,\r\n}\r\n\"TextField\":{\r\n borderColor: \"gray\",\r\n borderWidth: 1,\r\n width: Ti.UI.FILL,\r\n}\r\n\r\n\".customFont\" : {\r\n font: {\r\n fontSize: 20, \r\n },\r\n color : \"#ff0000\"\r\n}\r\n\r\n\".as\": {\r\n attributes: [\r\n {\r\n type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,\r\n value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,\r\n range: [0, 2]\r\n }\r\n ]\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS parity issue : TextArea with AttributedString and font style ", "creator": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "subtasks": [], "reporter": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "environment": "TiSDK 5.2.2\r\niOS 9.3\r\nAndroid 6.x", "comment": { "comments": [ { "id": "385588", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello [~yomybaby], when you add a font property it manipulates the value in the specified way, however when you add an attributedString after the creation it overwrite the value property. To put in other words the attributedString takes precedence, if you look at the apple [docs|https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/#//apple_ref/occ/instp/UITextView/attributedText] it states that the attributedString replaces the value property. \r\n\r\nTo give a quick example run the code provided, if you specify the attributedString upon creation the font will be applied to the value which is the attributed string. However if you do it after creation the font has already been applied to the value,which then gets replaced by the attributed string. \r\n\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: 'white'\r\n});\r\n\r\nvar attr = Titanium.UI.createAttributedString({\r\n text: \"TextArea with attributedString in JS\",\r\n attributes: [\r\n {\r\n type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,\r\n value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,\r\n range: [0, 2]\r\n }\r\n ]\r\n});\r\n\r\nvar textArea = Ti.UI.createTextArea({\r\n color: '#ff0000',\r\n attributedString:attr,\r\n font: {fontSize:20, fontWeight:'bold'},\r\n top:40\r\n \r\n});\r\n\r\n\r\nvar textArea2 = Ti.UI.createTextArea({\r\n value:\"TextArea with attributedString in JS\",\r\n color: '#ff0000',\r\n font: {fontSize:20, fontWeight:'bold'},\r\n top:80\r\n \r\n});\r\n\r\ntextArea2.attributedString = attr;\r\n\r\nwin.add(textArea);\r\nwin.add(textArea2);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-12T22:24:33.000+0000", "updated": "2016-05-12T22:24:51.000+0000" }, { "id": "385848", "author": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "body": "Thanks for detail reply with example code. :)\r\nCode Strong~", "updateAuthor": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "created": "2016-05-17T01:11:11.000+0000", "updated": "2016-05-17T01:11:11.000+0000" }, { "id": "386818", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "You're very welcome, glad it helped :). Code Strong!", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-25T22:30:12.000+0000", "updated": "2016-05-25T22:30:12.000+0000" }, { "id": "388737", "author": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "body": "@apetkov\r\nI have a question.\r\nTextField and TextArea are using `UITextView`, aren't?\r\nI was wondering why TextField work as my expectation, but why TextArea isn't.\r\n", "updateAuthor": { "name": "yomybaby", "key": "yomybaby", "displayName": "Jong Eun Lee", "active": true, "timeZone": "Asia/Tokyo" }, "created": "2016-06-21T11:31:44.000+0000", "updated": "2016-06-21T11:34:41.000+0000" }, { "id": "388789", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It works for TextField ? If so thats a very good point, I will investigate. Very good catch, thank you! ", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-21T22:53:35.000+0000", "updated": "2016-06-21T22:53:35.000+0000" }, { "id": "390735", "author": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi, when setting the attributedString property its actually the same method inherited by a parent class for both textArea and textField. However the main difference is textArea is calling the native method \"setAttributedText\" on \"UITextView\", however textField is calling the native method on 'UITextField\" . \r\n\r\nThis seems to be a known bug after doing some searching through stack [seText|http://stackoverflow.com/questions/19049917/uitextview-font-is-being-reset-after-settext] [setAttributed|http://stackoverflow.com/questions/27499798/calling-setattributedtext-on-uitextview-resets-the-font-size-and-i-cant-figure]. I tried to implement the proposed \"work-around\" using the selectable property however it didn't seem to work, either way it's a workaround so it wouldn't be best practice to add it. ", "updateAuthor": { "name": "apetkov", "key": "apetkov", "displayName": "Angel Petkov", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-14T21:25:54.000+0000", "updated": "2016-07-14T21:25:54.000+0000" }, { "id": "420721", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing issue as this is not our bug.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-05-31T22:25:39.000+0000", "updated": "2017-05-31T22:25:39.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }