2010-12-03 13 views
2

私はUIViewの中央でスケーリングリングを作成しようとしています。UIImageViewをUIViewの中央でスケーリングする

セットアップは以下の通りです:IBで

、私はそれに接続されているビューと私のImageViewの(リング付き単に透明PNG)を持っています。 ImageView(theRing)にIBOutletを設定し、アクションをトリガーするボタンをクリックします。

ImageViewがIBの«scaleToFill»に設定されています。

アクションのコードがある:今

-(IBAction)buttonPressed:(id)sender{ 

    CGRect theFrame = theRing.frame; 

    theFrame.size.width = 16; 
    theFrame.size.height = 16; 

    [theRing setFrame:theFrame]; //Scale down the ring first 
    theRing.center = [self.view center]; // Center the ring in the center of the view 

    theFrame.size.width = 300; 
    theFrame.size.height = 300; 

    [theRing setAlpha:1.0]; 

    [UIView beginAnimations:nil context:nil]; 
    [UIView setAnimationDuration:1.0]; 

    [theRing setFrame: theFrame]; 
    [theRing setAlpha:0.0]; 
    theRing.center = [self.view center]; 

    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector: @selector(animEnd:finished:context:)]; 
    [UIView commitAnimations]; 

} 

- 私がボタンを最初にヒットしたときに、画像が基準点がImageViewの(手段の左上隅であるとスケーリングされ、それはスケールリングは画面の右下に広がります)。

しかし、私がもう一度ボタンを押すと、すべてが期待どおりに機能します(つまり、リングは画面の中央に残り、スケーリングされます)。

アイデア?

答えて

0

アスペクトが

+0

感謝を記入ImageViewのモードを使用しよう - それは...まだ最初の試行では動作しません助けにはなりませんでした... – Swissdude

関連する問題