Appcelerator钛标签ellipsize = TEXT_ELLIPSIZE_TRUNCATE_CHAR_WRAP不添加省略号

时间:2018-09-17 18:38:07

标签: appcelerator-titanium

说明

从文档here中,我认为将标签的ellipsize属性设置为TEXT_ELLIPSIZE_TRUNCATE_CHAR_WRAP应该在被截断的文本的末尾添加一个椭圆,但这只是在截断文本而不添加椭圆。

环境

  • Titanium SDK:7.4.1.GA
  • JavaScript引擎:V8
  • 平台和版本:iOS
  • 11.4设备详细信息:iOS模拟器(iPhone 7 +)
  • 主机操作系统:OS X 10.13 64位
  • 节点版本:7.10.0
  • Titanium CLI:5.1.1
  • Npm版本:4.2.0

解决方法

默认的椭圆尺寸设置(TEXT_ELLIPSIZE_TRUNCATE_END)确实会添加椭圆。因此,不确定TEXT_ELLIPSIZE_TRUNCATE_CHAR_WRAP和TEXT_ELLIPSIZE_TRUNCATE_END之间的预期区别是什么。

示例应用

创建一个示例性的经典钛应用程序,并将此代码放入您的app.js中:

var win = Ti.UI.createWindow();

// Expected: Only show 1 line with ellipses at the end
// Actual: Only shows 1 line truncated text, but no ellipses
var label_char_setting = Ti.UI.createLabel({
    text: 'This is a long label that should not wrap and instead ellipsize after last fitting character',
    width: 200,
    top: '35%',
    ellipsize: Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_CHAR_WRAP,
    wordWrap: false,
    font: {
        fontSize: 16
    },
    maxLines: 1
});

// Expected: Only show 1 line with ellipses at the end
// Actual: As expected
var label_default_setting = Ti.UI.createLabel({
    text: 'This is a long label that should not wrap and instead ellipsize after last fitting character',
    width: 200,
    top: '50%',
    ellipsize: Ti.UI.TEXT_ELLIPSIZE_TRUNCATE_END,
    wordWrap: false,
    font: {
        fontSize: 16
    },
    maxLines: 1
});

win.add([label_char_setting, label_default_setting]);

win.open();

// added during app creation. this will automatically login to
// ACS for your application and then fire an event (see below)
// when connected or errored. if you do not use ACS in your
// application as a client, you should remove this block
(function(){
var ACS = require('ti.cloud'),
    env = Ti.App.deployType.toLowerCase() === 'production' ? 'production' : 'development',
    username = Ti.App.Properties.getString('acs-username-'+env),
    password = Ti.App.Properties.getString('acs-password-'+env);

// if not configured, just return
if (!env || !username || !password) { return; }
/**
 * Appcelerator Cloud (ACS) Admin User Login Logic
 *
 * fires login.success with the user as argument on success
 * fires login.failed with the result as argument on error
 */
ACS.Users.login({
    login:username,
    password:password,
}, function(result){
    if (env==='development') {
        Ti.API.info('ACS Login Results for environment `'+env+'`:');
        Ti.API.info(result);
    }
    if (result && result.success && result.users && result.users.length){
        Ti.App.fireEvent('login.success',result.users[0],env);
    } else {
        Ti.App.fireEvent('login.failed',result,env);
    }
});

})();

结果

Screenshot Bug Repro

0 个答案:

没有答案