A CEikLabel is a basic component use to display static text in a control. It is fairly easy and straightforward to use as soon as you don't have to change its color: there is no SetColor() primitive.
If you are reading this page, you are probably looking for the answer. And as usual in the Symbian world, it is pretty trivial once you know how to do it. As a matter of fact, you have to override the EColorLabelText setting of your label using the OverrideColorL() primitive. The code below shows how to do this:
-----------------------------------------------------------------------------------------------------------------------------------
CCoeEnv::Static()->NormalFont()
CEikonEnv::Static()->AnnotationFont()
CEikonEnv::Static()->TitleFont()
CEikonEnv::Static()->LegendFont()
CEikonEnv::Static()->SymbolFont()
CEikonEnv::Static()->DenseFont()
改变字体
在第三版的可以这样
CFont *font = NULL;
TFontSpec fontSpec = iEikonEnv->TitleFont()->FontSpecInTwips();
fontSpec.iHeight *= 0.8;
iCoeEnv->ScreenDevice()->GetNearestFontInTwips(font,fontSpec);
_LIT(KMyFontName,"Swiss");
TFontSpec myFontSpec1(KMyFontName,200);
CFont* myFont1;
//加粗
myFontSpec1.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
//斜体
myFontSpec1.iFontStyle.SetPosture(EPostureItalic);
//阳文
myFontSpec1.iFontStyle.SetEffects(FontEffect::EEmbossed,ETrue);
//获取字体
iFbsScreenDevice->GetNearestFontToMaxHeightInTwips(myFont1, myFontSpec1, 220);
//选择字体
iFbsBitGc->UseFont(myFont1);
//设置画笔颜色为红色
iFbsBitGc->SetPenColor(KRgbRed);
_LIT(KText, "This is a Test!");
TBufC<20> text (KText);
iFbsBitGc ->DrawText(text, TPoint(120, 200));
iFbsScreenDevice->Update();
// Discard and destroy the font
iFbsScreenDevice->ReleaseFont(myFont1);
...
// Basic Label Construction
CEikLabel* myLabel;
myLabel= new (ELeave) CEikLabel;
myLabel->SetContainerWindowL( *this );
myLabel->SetTextL( _L("NewLC rulez!") );
// Now Set the foreground color
myLabel->OverrideColorL( EColorLabelText, KRgbRed );
// and the background color
myLabel->OverrideColorL(EColorControlBackground, KRgbWhite );