繁体   English   中英

iOS UIDynamics附件行为显示了这一行

[英]iOS UIDynamics attachment behavior showing the line

是否可以将UIDynamicBehaviors配置为显示使用UIDynamics附加行为附加两个UIView的“行”?

看一下您可以在Apple开发人员网站上找到的DynamicsCatalog 您将看到一条虚线,它将在APLDecorationView类中绘制 UIAttachmentBehavior仅负责处理指定元素之间的附件,而不绘制任何连接。

  1. 因此,如果要在项目中使用它, APLDecorationView.h在文件中插入APLDecorationView.h
  2. 初始化应在其中添加绳索的UIViews ,请使用以下方法:

     trackAndDrawAttachmentFromView:toView:withAttachmentOffset: 
  3. 在方法内部自定义应显示的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM