[英]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.