是否可以配置UIDynamicBehaviors以显示" line"使用UIDynamics附件行为附加两个UIView?
答案 0 :(得分:3)
查看您在Apple开发者网站上可以找到的DynamicsCatalog。您将看到一个虚线,它将在类APLDecorationView中绘制。 UIAttachmentBehavior
负责处理未绘制任何连接的指定元素之间的附件。
APLDecorationView.h
在你的档案里面。当您的UIViews
应该添加绳索时,已初始化,请使用以下方法:
trackAndDrawAttachmentFromView:toView:withAttachmentOffset:
UIImage
,可能是大小。就我而言,它看起来像这样:
[(APLDecorationView *)self trackAndDrawAttachmentFromView:self.viewOne
toView:self.viewTwo
withAttachmentOffset:CGPointZero];
这是我APDecorationView
的修改:
NSInteger iRopeElements = ( isiPad ) ? 15 : 20;
for (NSUInteger i=0; i < iRopeElements; i++)
{
UIImage *ropeElement = [UIImage imageNamed:@"rope_element"];
CALayer *layerRope = [CALayer layer];
layerRope.contents = (__bridge id)(ropeElement.CGImage);
CGFloat fRopeWidth = attachedView.frame.size.width * 0.3f;
layerRope.bounds = CGRectMake(0, 0, fRopeWidth, fRopeWidth / 1.64f);
layerRope.anchorPoint = CGPointMake(0.5, 0);
[self.layer insertSublayer:layerRope atIndex:0];
[self.attachmentDecorationLayers addObject:layerRope];
}