[英]iOS UIDynamics attachment behavior showing the line
是否可以将UIDynamicBehaviors配置为显示使用UIDynamics附加行为附加两个UIView的“行”?
看一下您可以在Apple开发人员网站上找到的DynamicsCatalog 。 您将看到一条虚线,它将在APLDecorationView类中绘制 。 UIAttachmentBehavior
仅负责处理指定元素之间的附件,而不绘制任何连接。
APLDecorationView.h
在文件中插入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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.