Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24071] iOS: Expose Ti.UI.Label maxLines (Parity)

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-10-26T11:51:18.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.1.0
ComponentsiOS
Labelsios, label, maxlines, notable, parity
ReporterCarlos Henrique Zinato
AssigneeHans Knöchel
Created2016-10-25T15:18:00.000+0000
Updated2017-05-29T11:18:47.000+0000

Description

Add support for numberOfLines property on UILabel component: https://developer.apple.com/reference/uikit/uilabel/1620539-numberoflines?language=objc It should be called *maxLines* to allow a better cross-platform implementation PR: https://github.com/appcelerator/titanium_mobile/pull/8543 Example:
var win = Ti.UI.createWindow({
   backgroundColor: '#ffffff'
});

var testLabel = Ti.UI.createLabel({
   text:"The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog",
   color:'black',
   width:'50%',
   maxLines:1
});

win.add(testLabel)
win.open();
Expected: Changing the property maxLines, the label should expand accordingly the value

Comments

  1. Hans Knöchel 2016-10-26

    Test-case (checking getter, setter and UI-change):
       var win = Ti.UI.createWindow({
           backgroundColor: '#ffffff'
       });
       
       var testLabel = Ti.UI.createLabel({
           text: "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog",
           color: 'black',
           top: 100,
           width: 200,
           maxLines: 1
       });
       
       var btn = Ti.UI.createButton({
           title: "Change \"maxLines\" to 3",
           top: 50
       });
       
       btn.addEventListener("click", function() {
           Ti.API.warn("Current # of liens: " + testLabel.getMaxLines());
           testLabel.setMaxLines(3);
           Ti.API.warn("New # of liens: " + testLabel.getMaxLines());
       });
       
       win.add(btn);
       
       win.add(testLabel)
       win.open();
       
  2. Hans Knöchel 2016-10-26

    [~bimmel] Added the notable label to honor [~chmiiller]'s contribution in the 6.1.0 release notes.
  3. Eric Wieber 2016-11-17

    Verified implemented, using: MacOS 10.12 (16A323) Studio 4.8.0.201611121409 Ti SDK 6.1.0.v20161117072812 Appc NPM 4.2.9-1 Appc CLI 6.1.0-13 Alloy 1.9.4 Xcode 8.1 (8B62) Verified that maxLines can be get, set, and directly referenced as a property of a Ti.UI.Label.

JSON Source