안녕하세요 저는 이미지 뷰의 오른쪽 모서리를 드래그하여 이미지 뷰의 크기를 조정하고 회전해야하는 요구 사항이 있습니다.이미지 뷰의 오른쪽 모서리를 드래그하여 이미지 뷰의 크기를 조정하고 회전하는 방법
모서리를 드래그하여 이미지보기의 크기를 조정할 수는 있지만 한 손가락으로 이미지보기의 크기 조정 회전 기능을 구현할 때 실패했습니다.
내 요구 사항을 달성 할 수있는 사람을 안내해 줄 수있는 사람이 있습니까?
이미지 뷰의 모서리에서 크기를 조정하기위한 코드를 아래에 추가했습니다.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
touchStart = [[touches anyObject] locationInView:self];
isResizingLR = (self.bounds.size.width - touchStart.x < kResizeThumbSize && self.bounds.size.height - touchStart.y < kResizeThumbSize);
isResizingUL = (touchStart.x <kResizeThumbSize && touchStart.y <kResizeThumbSize);
isResizingUR = (self.bounds.size.width-touchStart.x < kResizeThumbSize && touchStart.y<kResizeThumbSize);
isResizingLL = (touchStart.x <kResizeThumbSize && self.bounds.size.height -touchStart.y <kResizeThumbSize);
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self];
CGPoint previous=[[touches anyObject]previousLocationInView:self];
float deltaWidth = touchPoint.x-previous.x;
float deltaHeight = touchPoint.y-previous.y;
if (isResizingLR) {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,touchPoint.x + deltaWidth, touchPoint.y + deltaWidth);
}
if (isResizingUL) {
self.frame = CGRectMake(self.frame.origin.x + deltaWidth, self.frame.origin.y + deltaHeight, self.frame.size.width - deltaWidth, self.frame.size.height - deltaHeight);
}
if (isResizingUR) {
self.frame = CGRectMake(self.frame.origin.x ,self.frame.origin.y + deltaHeight, self.frame.size.width + deltaWidth, self.frame.size.height - deltaHeight);
}
if (isResizingLL) {
self.frame = CGRectMake(self.frame.origin.x + deltaWidth ,self.frame.origin.y , self.frame.size.width - deltaWidth, self.frame.size.height + deltaHeight);
}
if (!isResizingUL && !isResizingLR && !isResizingUR && !isResizingLL) {
self.center = CGPointMake(self.center.x + touchPoint.x - touchStart.x,self.center.y + touchPoint.y - touchStart.y);
}
} 나는 이런 식으로 뭔가를 생각하는 어떤 코드없이
고마워요 Spynet,하지만이 코드는 내가 크기를 조정하는 데 도움이 오히려 내가 몇 가지 샘플을 크기를 조정하는 것과 같은 방식으로 imageView를 회전해야합니다 ... –
@vivek 코드가 회전하고 싶어? ...? – Spynet
@vivek 코드 검사를 업데이트했습니다 ... – Spynet