[TIMOB-24071] iOS: Expose Ti.UI.Label maxLines (Parity)
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-10-26T11:51:18.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | iOS |
| Labels | ios, label, maxlines, notable, parity |
| Reporter | Carlos Henrique Zinato |
| Assignee | Hans Knöchel |
| Created | 2016-10-25T15:18:00.000+0000 |
| Updated | 2017-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
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();[~bimmel] Added the
notablelabel to honor [~chmiiller]'s contribution in the 6.1.0 release notes.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.