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
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
CheatSheet

Xcodeの便利なショートカットキー 良く使ってるなと感じたら追記 Cmd+Al …

no image
NSLog まとめ

デバッグする時などに、ログを出力する方法としてNSLogを使用します。 文字列を …

eyechatch_xcode_tips-300x300
LaunchImage 関連の設定

▼アプリ起動時のスプラッシュ画面 通常はチラっと一瞬だけ表示されるスプラッシュ画 …

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

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

no image
NSArray valueForkeypath関数

NSArrayやNSDictionaryを多用する人にお勧めですCoreData …

no image
乱数のこと

乱数(ランダムな数)を取り出す際 rand や arc4random を使用しま …

no image
画面ローテーション

画面ローテーションを制御する場合は下記を追加する – (BOOL)s …

no image
アプリの名前をつける

iPhoneのホーム画面に表示される「アプリ名」の付け方 アプリ名の変更には上 …

eyechatch_xcode_tips-300x300
.selected

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