2013-07-09 12 views
1

나는 순환 그라디언트를 포함하는 ImageView과 뷰 또는 흰색 배경에있는 UISliders의 간섭을 방지하기 위해 그라디언트를 구체적으로 제한하고자하는 panGestureRecognizer을 가지고 있습니다.팬 제스처 인식기를 ImageView로 제한 하시겠습니까?

그래디언트 내의 터치 만 인식합니까? 지금 현재로

, 나는 나쁜 결과를이 방정식을 사용하고 있습니다 :이 변수는 그라데이션의 중심을 표시하는 데 사용됩니다

 CGPoint lastPoint = [sender locationOfTouch: sender.numberOfTouches - 1 inView: gradientView]; 
     CGPoint center = CGPointMake((size.width/2), (size.height /2)); 

.

 if((lastPoint.x - center.x) + (lastPoint.y - center.y)/2 < radius) 
     { 
      UIColor *color = [UIColor colorWithHue: angle/(M_PI * 2.0) saturation:saturationSlider.value brightness:hellSlider.value alpha:alphaSlider.value]; 
      if ([color getRed: &r green: &g blue:&b alpha: &a]) 
      { 
       NSLog(@"Color value - R : %g G : %g : B %g", r*255, g*255, b*255); 
      } 
      float red = r; 
      float green = g; 
      float blue = b; 
      rText.text = [NSString stringWithFormat:@"%.0f",rSlider.value]; 
      gText.text = [NSString stringWithFormat:@"%.0f",green*255]; 
      bText.text = [NSString stringWithFormat:@"%.0f",blue*255]; 


      colorView.backgroundColor = [UIColor colorWithRed:(rText.text.floatValue/255) green:(gText.text.floatValue/255) blue:(bText.text.floatValue/255) alpha:alphaSlider.value]; 
      rSlider.value = red*255; 
      gSlider.value = green*255; 
      bSlider.value = blue*255; 
      alphaText.text = [NSString stringWithFormat:@"%.2f",alphaSlider.value]; 
      brightnessText.text = [NSString stringWithFormat:@"%.2f",hellSlider.value]; 
      saturationText.text = [NSString stringWithFormat:@"%.2f",saturationSlider.value]; 

     } 

위의이 코드는 내 panGestureRecognizer의 방법 안에이 방정식이다.

답변

0

해당 원형 뷰의 맨 위에 다른 UIView을 추가하고 해당 뷰에 제스처를 적용 할 수 있습니다.

UIView *gestureView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; 
[gestureView.layer setCornerRadius:gestureView.frame.size.width/2]; 

이렇게하면 원형 UIView을 줄 것이다. 필요에 따라 크기와 위치를 조정하십시오.

+0

나는 그것을 시도 할 것이다! 덕분에 – Exothug

+0

이것은 뷰 아래의 그라디언트를 비활성화하지 않습니다. 그래도 눈에 보이는 그라데이션 바운드 바깥으로 드래그하더라도 색상이 표시됩니다. – Exothug

+0

여기서 실제로 달성하고자하는 것은 무엇입니까? 터치 영역 또는 다른 것을 제한하고 싶습니까? –

관련 문제