我下载了苹果“DynamicsCatalog.xcodeproj”的示例代码,我遇到了这个问题
- (void)viewDidLoad
{
[super viewDidLoad];
UIDynamicAnimator* animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
UICollisionBehavior* collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[self.square1]];
CGPoint squareCenterPoint = CGPointMake(self.square1.center.x, self.square1.center.y - 100.0);
CGPoint attachmentPoint = CGPointMake(-25.0, -25.0);
/*
By default, an attachment behavior uses the center of a view. By using a small offset, we get a more interesting effect which will cause the view to have rotation movement when dragging the attachment.
*/
UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.square1 point:attachmentPoint attachedToAnchor:squareCenterPoint];
collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;
// Show visually the attachment points
self.redSquare.center = attachmentBehavior.anchorPoint;
self.blueSquare.center = CGPointMake(25.0, 25.0);
[animator addBehavior:attachmentBehavior];
self.animator = animator;
self.attachmentBehavior = attachmentBehavior;
}
我在哪里替换这条线:
UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.square1 attachedToAnchor:squareCenterPoint];
用这条线:
UIAttachmentBehavior *attacheMentBehavior = [[UIAttachmentBehavior alloc] initWithItem:self.square1 offsetFromCenter:attachmentPoint attachedToAnchor:squareCenterPoint];
但我收到此错误:
将 cgpoint 又名击中 cgpoint 发送到不兼容类型 UIOffset 又名击中 UIOffset 的参数
如果您能告诉我我做错了什么或如何解决此问题,我将不胜感激。
谢谢