11月 21 2009

テキストをプログラムで調整する。

Posted by dos in iphone, iphone Tips

テキストをプログラムで調整する方法の一例を記述したいと思います。

UILabel *label;

//配置座標と範囲

label = [[UILabel alloc] initWithFrame:CGRectMake(170.0f, 372.0f, 135.0f, 20.0f)];

//背景のアルファ値を0.0にする

label.backgroundColor = [UIColor clearColor];

//フォントサイズ

label.font = [UIFont systemFontOfSize:14];

//テキストを右字詰め

labele.textAlignment = UITextAlignmentRight;

//RGBとアルファ値を調整

label.textColor = [[UIColor alloc] initWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];

と記入する。

ちなみに太字で表示したい場合はフォントサイズの記述を

labele.font = [UIFont boldSystemFontOfSize:14];

と記入します。斜体の場合も同じ様にありますので調べてみるとよいでしょう♪

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>