I am using slightly adapted code from apple Binding Code (I just changed the variable name in the image):
- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { UIView *image = gestureRecognizer.view; CGPoint locationInView = [gestureRecognizer locationInView:image]; CGPoint locationInSuperview = [gestureRecognizer locationInView:image.superview]; // Gives error: Property 'anchorPoint' not found on object of type 'CALayer *' //image.layer.anchorPoint = CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height); // Gives warning: Method '-setAnchorPoint' not found [image.layer setAnchorPoint:CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height)]; image.center = locationInSuperview; } }
However, as indicated in the comments, image.layer.anchorPoint does not compile with an inability to find the "anchorPoint" property error. It compiles when a string is overwritten with a message, but it still gives a warning.
Copying and pasting Touches code directly without changing the variable name gives the same error. Also, these errors do not appear when compiling Touches code.
Why is this?
source share