0
我有以下情況,我試圖做一個照片編輯器,我需要做的規模,翻譯和周圍的景色中心旋轉操作的圖像變換旋轉和平移問題
的問題是,如果我申請之後90度翻譯:左邊是翻譯頂部和錨點是不是該視圖的轉換後的中心
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
// ImageView
v = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 500)];
[v setBackgroundColor:[UIColor redColor]];
// ImageView's Image
UIImage *img = [UIImage imageNamed:@"_my.jpg"];
[v setImage:img];
v.contentMode = UIViewContentModeScaleAspectFit;
v.layer.anchorPoint = CGPointMake(0.5, 0.5);
[self.view setBackgroundColor:[UIColor clearColor]];
// UiView containing ImageView
vc = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 500)];
[vc addSubview:v];
[self.view addSubview:vc];
}
- (IBAction)Click:(id)sender {
// Translate
if ([sender tag] == 1) {
CGAffineTransform t0 = v.transform;
CGAffineTransform t1 = CGAffineTransformTranslate(t0, 10.0, 0.0);
v.transform = t1;
}
// Rotate
if ([sender tag] == 2) {
CGAffineTransform t0 = v.transform;
CGAffineTransform t1 = CGAffineTransformRotate(t0, DEGREES_TO_RADIANS(10));
v.transform = t1;
}
}
有誰知道我怎麼能保持的中心視場爲錨點和後翻譯旋轉才能正常工作?
TX
容易它刪除翻譯,應用旋轉,然後應用轉換回http://en.wikipedia.org/wiki/Transformation_(function方式) – SAKrisT
我需要翻譯,規模和多次旋轉動作任何順序,目標是用戶可以做任何他想要的圖像,以適應它在裁剪區域 –
好吧,但無論如何它應該有正確的轉換順序檢查這個http://www.cosc.brocku.ca/產品/ 3P98 /課程/講座/ 2d_3d_xforms / – SAKrisT