Tabs

iPhone&Androidのアプリ制作・デザイン

*

テキストの文字間を詰める

   


UILabelなどで文字間を詰める(カーニング)したい時がちょいちょいあると思います。
覚えたことをメモメモ…
以下、ラベルにテキストを貼ってからの作業です。

// Hogeラベルの文字間を詰める
NSMutableAttributedString *attributedText =                  [[NSMutableAttributedStringalloc]initWithString:Hoge_Label.text];

[attributedText addAttribute:NSKernAttributeName value:
[NSNumber numberWithFloat:-0.1] range:NSMakeRange(0, attributedText.length)];

Hoge_Label.attributedText = attributedText;

numberWithFloat:(0.0f) で文字間を詰めることが出来ます。
0がデフォルトです。


 - Begin

  関連記事

eyechatch_xcode_tips-300x300
.selected

インスタンス名.selected で BOOLを宣言せずにボタンのON/OFF状 …

eyechatch_xcode_tips-300x300
ボタンに画像(背景)を指定する

// ボタンのサイズを指定する UIButton *startBtn = [[U …

no image
UIImageViewにボタンを貼りたい場合

タイトル画面などを作りたい場合、UIImageViewを使用して背景などを作るこ …

no image
UILabelをコードで生成(Tips付)

Main Storyboard (IB)に用意されている Label を使わずに …

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

eyechatch_xcode_tips-300x300
transform中の座標取得

CGAffineTransformを使用して画像を変化させている最中の座標取得方 …

no image
SubViewの重ね順を変更する

SubViewの重ね順を最前面に移動する場合 bringSubviewToFro …

no image
for文の便利な使い方

for文を使って繰り返し実行させる場合、基本的には数値を使ってループさせます。 …

eyechatch_xcode_tips-300x300
負の数を絶対数へ変換 abs

負の数を自然数(マイナスを含まない数字)にしたくて、「Xcode 自然数 変換」 …

eyechatch_xcode_tips-300x300
SNS連携

Twitter・Facebookとの連携は #import <Social …