Tabs

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

*

transform中の座標取得

      2015/01/18


CGAffineTransformを使用して画像を変化させている最中の座標取得方法は下記の通りです。

UIImageView *hoge;
CALayer *layer = hoge.layer.presentationLayer;
float hogeY = [[layer valueForKeyPath:@”transform.translation.y”]floatValue];
これで移動中のy座標を取得できます。

また、変化中の画像の大きさ(width)の値を知りたい場合は

CALayer *layer = hoge.layer.presentationLayer;
float hogeW = [[layer valueForKeyPath:@”transform.scale.x”]floatValue];
となります。

画像の大きさなので「width」だから「transform.scale.w」と思いがちですが、
「transform.scale.x」となるので注意が必要です。

float hogeX = [[layer valueForKeyPath:@”transform.translation.x”]floatValue];
float hogeY = [[layer valueForKeyPath:@”transform.translation.y”]floatValue];
float hogeW = [[layer valueForKeyPath:@”transform.scale.x“]floatValue];
float hogeH = [[layer valueForKeyPath:@”transform.scale.y“]floatValue];


 - Begin

  関連記事

no image
乱数のこと

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

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

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

eyechatch_xcode_tips-300x300
Xcode6 GameCenter 実装

Xcode6(iOS7以上)でのGameCenter実装 検索であまり見つからな …

no image
画面ローテーション

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

eyechatch_xcode_tips-300x300
SNS連携

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

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

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

eyechatch_xcode_tips-300x300
UIButton 同時押し制御

UIButton *myBtn = [UIButton alloc] init] …

no image
iPhone画面サイズ

3.5inch 320 x 480px (Retina 640 x 960px) …

eyechatch_xcode_tips-300x300
UIViewの背景画像をフィットさせたい

UIViewは(UIImageViewとは違い)背景画像のサイズをフィットする機 …

eyechatch_xcode_tips-300x300
配列にNSNumberをぶちこむ

配列から数値を直に取り出したい場合はどうするのかと調べてみたのでメモ。 NSNu …