簡體   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