スキップしてメイン コンテンツに移動

投稿

7月, 2013の投稿を表示しています

String Format Specifiers

This article summarizes the format specifiers supported by string formatting methods and functions. Format Specifiers The format specifiers supported by the  NSString  formatting methods and CFString formatting functions follow the  IEEE printf specification ; the specifiers are summarized in  Table 1 . Note that you can also use the “ n$ ” positional specifiers such as  %1$@ %2$s . For more details, see the  IEEE printf specification . You can also use these format specifiers with the  NSLog  function. Table 1   Format specifiers supported by the  NSString  formatting methods and CFString formatting functions Specifier Description %@ Objective-C object, printed as the string returned by  descriptionWithLocale:  if available, or  description  otherwise. Also works with CFTypeRef  objects, returning the result of the  CFCopyDescription  function. %% '%'  character. %d ,...

CABasicAnimationの基本的な使い方(移動・回転・拡大・縮小)

CABasicAnimationクラスを使用することで基本的なキーフレームアニメーションを行うことができます. キーフレームアニメーションとはレイヤーの属性をキーパスとして登録し,アニメーションの開始と終了を指定することで自動的に中間のアニメーションを計算させて作るアニメーションです. CABasicAnimationの基本的な使用手順 1.QuartzCore.frameworkの追加 「QuartzCore.framework」が入っていない場合はプロジェクトに追加します.また,CABasicAnimationを使用するクラスで「QuartzCore/QuartzCore.h」をインポートします. 1 #import <QuartzCore/QuartzCore.h> 2.CABasicAnimationのインスタンス化とキーパスの登録 「animationWithKeyPath:」メソッドを使用し,CABasicAnimationをインスタンス化します.その際にアニメーションに使用するレイヤーの属性をキーパスとして指定します.(キーパスは「keyPath」プロパティを使用することで後から指定することもできます) 1 2 3 // positionプロパティを指定 CABasicAnimation *animation =      [CABasicAnimation animationWithKeyPath:@ "position" ]; 3.アニメーションの設定 アニメーションのオプションを設定します.指定できるプロパティには以下のようなものがあります. プロパティ 説明 duration アニメーションの速度を指定 repeatCount 繰り返し回数を指定.永久に繰り返すにはHUGE_VALFを指定します. beginTime アニメーションの開始時刻を指定.開始を指定秒数遅らせるには 「CACurrentMediaTime() + 秒数」の形式で指定します. timingFunction アニメーション速度の変化を指定 autoreverses アニメーション終了時に逆アニメーションを実行す...