正方形の画像や円形の画像を変換するのは簡単です...
しかし、長方形の画像の場合はどうなりますか?
これは、タッチイベントで変換したい画像です。
画面上の任意の場所に触れると、円の中心は(30、236)になります
Imageviewは矢印を私のタッチポイントに変換します。
しかし、円の中心はまだ同じ場所です。
テスト角度を使用して画像を変換しようとします
こんな感じになります...
画像を調整する方法は?
また、コードはここにあります
- (void)viewDidLoad {
CGRect arrowImageRect = CGRectMake(20.0f, 20.0f, 15.0f, 220.0f);
arrow = [[UIImageView alloc] initWithFrame:arrowImageRect];
[arrow setImage:[UIImage imageNamed:@"arrow.png"]];
arrow.opaque = YES;
[self.view addSubview:arrow];
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchPoint = [touch locationInView:self.view];
NSLog(@"Position X: %f \n, Y: %f",touchPoint.x,touchPoint.y);
CGAffineTransform transform = CGAffineTransformIdentity;
arrow.transform = CGAffineTransformRotate(transform, ?????? );
}
?????? 一部は最後の解決策でなければなりません...
または多分私はimageviewのサイズを変更する必要があります???
返信や回答をありがとう:-)
ウェバー