1
我有一個imageview,我縮放和旋轉通過UISliders。這是我如何做到這一點:CGAffineTransform縮放和旋轉
- (IBAction)sizeSlider:(UISlider *)sender
{
int SCALE_MAX = 200;
int SCALE_MIN = 10;
CGAffineTransform transform = image.transform;
float scale = sqrt(transform.a*transform.a + transform.c*transform.c);
if (scale > SCALE_MAX)
image.transform = CGAffineTransformScale(transform, SCALE_MAX/scale*sender.value, SCALE_MAX/scale*sender.value);
else if (scale < SCALE_MIN)
image.transform = CGAffineTransformScale(transform, SCALE_MIN/scale*sender.value, SCALE_MIN/scale*sender.value);
}
- (IBAction)angleSlider:(UISlider *)sender
{
CGAffineTransform t = CGAffineTransformMakeRotation(sender.value);
image.transform = t;
}
這工作,但如果ImageView的已經從原來的大小縮放,然後旋轉圖像重置爲原始大小。我怎樣才能防止這一點?