gpt4 book ai didi

titanium - 如何更改 textField Titanium 中的 hintText 颜色?

转载 作者:行者123 更新时间:2023-12-02 09:34:18 28 4
gpt4 key购买 nike

这是我的代码,我想改变提示文本的颜色,怎么办?

    "#email":{
width: '70%',
left:'13%',
font:{
fontSize:'20sp'
},
color: '#fff',
hintText:'请输入手机号',
borderColor:'transparent',
bottom:'2%',
//backgroundColor:'#d9d9d9',
backgroundColor:'transparent',
borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
}

最佳答案

这也可以使用支持 Android 和 iOS 的 AttributedString 和 AttributedHintText 来完成。

var emailHintText = "Your email";

var attributedEmailHintText = Titanium.UI.createAttributedString({
text : emailHintText,
attributes : [{
type : Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
range : [0, emailHintText.length],
value : '#88817F',
}]
});

$.email.setAttributedHintText(attributedEmailHintText);

除了颜色之外,AttributedString 还允许您向字符串/提示文本添加更多属性。在 Appcelerators 文档中阅读相关信息:

AttributedString Foreground Color

Ti.UI.AttributedString

更新 15.08.16

在 Titanium SDK 5.4.0.GA 版本发布后,iOS 现在支持 TextFields 的属性 hintTextColor 和方法 setHintTextColor。在 Titanium SDK Release Notes for iOS 中阅读更多内容

关于titanium - 如何更改 textField Titanium 中的 hintText 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28801602/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com