0

So my code uses the CIFaceFeature for face detection and draws a CGRect around the face. I am trying to enable the user to move the rect around for any minor adjustments to be made using UITouch. But so far I'm unable to do so. I found this How can I move CGRect with UITouches? but it hasn't helped.

I've tried making the CGRect a subview of UIView and implementing it using the code mentioned here UIView drag (image and text) but it isn't working.

Any help would be appreciated thanks.

Community
  • 1
  • 1
geekchic
  • 2,371
  • 4
  • 29
  • 41
  • A CGRect is not a view, it's just a data structure representing a rectangle. So when you say that you draw a CGRect, do you mean that a UIView on the screen draws a CGRect? If so, you'll need to update the CGRect that the view draws (it should be an instance variable or property of the view), then call setNeedsDisplay on the view. – architectpianist Jul 31 '13 at 10:32
  • Ah, I mean I was aware that CGRect is not a view. But I was trying to use `findFace = [[UIImageView alloc] initWithFrame:result];` to put the CGRect in a view but clearly that wasn't working. Could you elaborate on how the UIView would draw the CGRect instead? – geekchic Jul 31 '13 at 12:32
  • I think I understand what you want - to draw the border around a region in `findFace` that may change over time. For this, you need to draw the rect into a separate view whose superview is the image view containing the entire image. Make this view transparent and set its layer's borderColor and borderWidth; then you can change the frame of this view as needed. Is that right? – architectpianist Jul 31 '13 at 23:15
  • Precisely! I want the user to be able to move the frame around a bit. – geekchic Aug 01 '13 at 05:05

1 Answers1

0

I have a sample project in

https://github.com/slysid/iOS/tree/master/FaceView

I think, this is might give you an idea

Bharath

slysid
  • 5,236
  • 7
  • 36
  • 59
  • This was pretty much what I needed! In hindsight, it seems too easy. But thank you! (I'm not sure whether SO qualifies this as an answer but it worked for me so..!) – geekchic Aug 01 '13 at 05:22