I tried to move CALayer with touch event. But there are error messages.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
// get touched point
CGPoint pt = [[touches anyObject] locationInView:self];
[self.layer convertPoint:pt toLayer:self.layer.superlayer];
// move piece to the point
piece.bounds.origin = pt; <- "Expression is not assignable"
}
}
I have look for solution of this problem, and reached to that this is problem of strucnt of Objective-C object. But I couldn’t get the solution.
Thanks for your kindness.
Yeah, it’s not assignable. The same goes for
UIViews and it’s subclasses.We can’t set a
CALayer.bounds.originorCALayer.bounds.sizeproperties. What we can do, is create aCGRectand assign it toCALayer.boundsorCALayer.frame.So, something like: