私は画像のクロッピングを変更するaccelerometer: didAccelerate
に配置されたこのコードチャンクを持っています。基本的に、あなたがiPadを傾けると、画像が切り捨てられ(はサイズ変更されず、)、これはまさに私が探している効果です。注:self.xPos
は、accelerometer.xの位置によって影響を受けます。UIView/UIImageViewのクロッピングをアニメ化する
UIImage *originalStringImage = [UIImage imageNamed:@"string.png"];
CGImageRef imageRef = CGImageCreateWithImageInRect([originalStringImage CGImage], CGRectMake(0.0f,0.0f, self.xPos+50.0f, 26.0f));
[self.stringImageView setImage:[UIImage imageWithCGImage:imageRef]];
self.stringImageView.frame = CGRectMake(10.0f, self.stringYPos, self.xPos+50.0f, 26.0f);
私はUIViewアニメーションとしても同じことをしたいと思います。これらのUIViewアニメーションパラメータの間の何か:
UIImageView *pageStringImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10.0f, placeString, 0.0f, 42.0f)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:2.0];
[UIView setAnimationDuration:3.0];
pageStringImageView.frame = CGRectMake(10.0f, placeString, 900.0f, 42.0f);
UIImage *originalStringImage = [UIImage imageNamed:@"string.png"];
CGImageRef imageRef = CGImageCreateWithImageInRect([originalStringImage CGImage], CGRectMake(10.0f,placeString, pageStringImageView.frame.origin.x, 42.0f));
[pageStringImageView setImage:[UIImage imageWithCGImage:imageRef]];
[UIView commitAnimations];
しかし、上記はすべて機能しません。実際、それはイメージを表示しません。ここでの主な難しさは、UIViewアニメーションの実行中にイメージのサイズを動的に変更することです。
提案や質問はありますか?
あなたの回答は非常に有益でした。よくやった! –
また、境界部分にクリップが差をつけました。それがなければ私はそれを働かせることができませんでした: 'imageview.clipsToBounds = YES' –