如何改变CEikLabel的颜色

本文介绍如何使用CEikLabel控件显示静态文本,并提供了修改文本颜色的方法,包括前景色和背景色的设置。此外,还介绍了如何改变字体、强调方式等。

CEikLabel的基本功能是在控件中显示静态文本,而且是支持双向显示文字的,如果应用语言是从右到左的风格,那么文字将会是右对齐的。 CEikLabel 没有提供 SetColor() 方法,但你千万不要以为那就没有办法修改CEikLabel 的颜色了。你需要通过 OverrideColorL() 进行设置,并用 SetEmphasis()启动设定,从而跳过标签的EColorLabelTextEmphasis设置。 Following is the sample Code: #include ... // construct CEikLabel CEikLabel* myLabel; myLabel= new (ELeave) CEikLabel; myLabel->SetContainerWindowL( *this ); myLabel->SetTextL( _L("NewLC rulez!") ); // Set the foreground color is red myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbRed ); myLabel->SetEmphasis( CEikLabel::EPartialEmphasis ); 如果需要同时设置前景色和背景色,那么在这情况下,你还是需要跳过然后启动EColorLabelHighlightFullEmphasis的设置: // Set the foreground color is right // Set the background color is red myLabel->OverrideColorL( EColorLabelTextEmphasis, KRgbWhite ); myLabel->OverrideColorL( EColorLabelHighlightFullEmphasis, KRgbRed ); myLabel->SetEmphasis( CEikLabel::EFullEmphasis ); PS: The following functionality can be used by the application developer: Change the text string, Change the font that Label uses to display text, Toggle between no emphasis, partial emphasis and full emphasis, Change the number of pixels between the lines, Toggle between using underlined text or not, Toggle between using strikethrough text or not, Toggle between wrapping the text or not, Set the width to be used when wrapping text, Set the number of lines to display. By default, the following configuration applies: Normal system font is used, Text properties are no emphasis, not underlining and not strikethrough, Default system spacing between lines is used, Default system word wrapping settings is used, The control does not gain focus.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值