質問

Square UIView Object testView_を作成し、ViewDidloadでこれを追加します。

- (void)viewDidLoad {
[super viewDidLoad];
CGRect initialRect = testView_.frame;
NSLog(@"before rotation: w %f h %f x %f y %f", initialRect.size.width, initialRect.size.height, initialRect.origin.x, initialRect.origin.y);
testView_.transform = CGAffineTransformMakeRotation(0.1);
NSLog(@"after rotation: w %f, h %f, x %f, y %f", testView_.frame.size.width, testView_.frame.size.height, testView_.frame.origin.x, testView_.frame.origin.y);
testView_.frame = initialRect;
NSLog(@"reassign: w %f, h %f, x %f, y %f", testView_.frame.size.width, testView_.frame.size.height, testView_.frame.origin.x, testView_.frame.origin.y);
}

私はこれをコンソールで受け取ります:

2011-04-27 12:30:32.492 Test[31890:207] before rotation: w 100.000000 h 100.000000 x 20.000000 y 20.000000
2011-04-27 12:30:32.494 Test[31890:207] after rotation: w 109.483757, h 109.483757, x 15.258121, y 15.258121
2011-04-27 12:30:32.495 Test[31890:207] reassign: w 117.873589, h 100.000000, x 11.063205, y 20.000000

フレーム値、特に最後の値の変更の背後にあるロジックを理解できませんでした。誰かが私を啓発できますか?ありがとう。

役に立ちましたか?

解決

uiviewクラス参照が表示されます ここ 変換プロパティを使用してビューのフレームを設定しないでください cgaffinetransformidentity.

変換されたビューの位置を変更したい場合は、使用する必要があります 中心 財産。サイズを調整する場合は、使用する必要があります 境界 財産。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top