简体   繁体   English

在Titanium中的iOS上更改选择器的字体颜色

[英]Change font colour of picker on iOS in Titanium

How can I change the text colour of a picker using Titanium on the iOS platform. 如何在iOS平台上使用Titanium更改选择器的文本颜色。

From the looks of it, I can only change the background colour, and I can only change the font colour on the Android platform. 从外观上,我只能更改背景颜色,并且只能更改Android平台上的字体颜色。

You should take a look at themes attributes like below: 您应该看一下以下主题属性:

<style name="PickerTheme" parent="Theme.AppCompat.Light">
    <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
</style>


<!-- Use this style for Spinners/Plain Pickers in default state -->
<style name="SpinnerItem">
    <item name="android:textColor">#ff0000</item>
</style>


<!-- Use this style for Spinners/Plain Pickers in selected/popup state -->
<style name="SpinnerDropDownItem">
    <item name="android:textColor">#ffffff</item>
    <item name="android:background">#20767a</item>
</style>

When creating a PickerRow, you can set the color property: 创建PickerRow时,可以设置color属性:

http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.PickerRow-property-color http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.PickerRow-property-color

If that doesn't work, then you can do same as the example which is in the link above (creating Labels and adding them to each PickerRow): 如果这不起作用,则可以与上面的链接中的示例相同(创建标签并将其添加到每个PickerRow):

var fruit = [ 'Bananas', 'Strawberries', 'Mangos', 'Grapes' ];

var column1 = Ti.UI.createPickerColumn();

for(var i=0, ilen=fruit.length; i<ilen; i++){
  var row = Ti.UI.createPickerRow();

  var label = Ti.UI.createLabel({
    color:'red',
    font:{fontSize:20,fontWeight:'bold'},
    text: fruit[i],
    textAlign:'left',
    width:'126'
  });

  row.add(label);
  column1.addRow(row);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM