Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 在单元格中使用纹理(ASyncDisplayKit)_Swift_Asyncdisplaykit - Fatal编程技术网

Swift 在单元格中使用纹理(ASyncDisplayKit)

Swift 在单元格中使用纹理(ASyncDisplayKit),swift,asyncdisplaykit,Swift,Asyncdisplaykit,我正在尝试对齐我的单元格的组件,但它不能正常工作。我相信,我只是不理解ASLayoutSpec背后的一些简单想法,所以我非常感谢您的帮助 我有一个单元格ASCellNode,当然它由ASTextNode asTextLabel、ASDisplayNode asBackView组成,它只是一个圆角textLabel的背景,以及一个asImageNode asSoundIcon asBackView应该比asTextLabel稍微高一点、宽一点,并且AsoundIcon应该位于asBackView的

我正在尝试对齐我的单元格的组件,但它不能正常工作。我相信,我只是不理解ASLayoutSpec背后的一些简单想法,所以我非常感谢您的帮助

我有一个单元格ASCellNode,当然它由ASTextNode asTextLabel、ASDisplayNode asBackView组成,它只是一个圆角textLabel的背景,以及一个asImageNode asSoundIcon

asBackView应该比asTextLabel稍微高一点、宽一点,并且AsoundIcon应该位于asBackView的右侧,如asBackView的右侧和AsoundIcon的左侧之间的4个点,并且应该垂直居中

我所拥有的是asSoundIcon不是垂直居中的,它离我想要的右边很远

我已经尝试了很多选项,这只是其中之一,我不明白为什么我的水平间距不起作用,以及如何使AsoundIcon垂直对齐

试着去掉线

let asSoundVerticalLayout = ASRelativeLayoutSpec(horizontalPosition: .start, verticalPosition: .center, sizingOption: .minimumSize, child: asSoundIcon)
并将下一行更改为:

let asSoundLayout = ASStackLayoutSpec(direction: .horizontal, spacing: 0.0, justifyContent: .start, alignItems: .center, flexWrap: .noWrap, alignContent: .start, lineSpacing: 0.0, children: [asOverlayLayout, asSoundIcon])
UPD

我试着做一个简单的练习

覆盖func viewDidLoad{ super.viewDidLoad //加载视图后,通常从nib执行任何其他设置。 viewNode.automaticallyManagesSubnodes=true viewNode.backgroundColor=UIColor.blue 让asBackView=ASDisplayNode asBackView.backgroundColor=UIColor.gray 设ASTEXTLABLE=ASTextNode asTextLabel.attributedText=NSAttributedString.initstring:Cum contencio studere,omnes Lunas perdere audax,velox animalises.,属性:[NSAttributedStringKey.foregroundColor:UIColor.blue,NSAttributedStringKey.font:UIFont.systemFontofSize:15] asBackView.automaticallyManagesSubnodes=true asBackView.style.flexGrow=1 asBackView.style.flexShrink=1 asBackView.layoutSpecBlock={asDisplayNode,中的asSizeRange 设asInsetSpec=ASInsetLayoutSpecinsets:UIEdgeInsetsMake6,12,6,36,子项:ASTEXTLABLE 返回asInsetSpec } 让asSoundIcon=ASNetworkImageNodecache:ASPINRemoteImageDownloader.shared,downloader:ASPINRemoteImageDownloader.shared asSoundIcon.setURLURL.initstring:https://www.shareicon.net/data/2017/02/09/878596_music_512x512.png,resetToDefault:false asSoundIcon.style.preferredSize=CGSizewidth:50,高度:50 viewNode.layoutSpecBlock={node,中的constrainedSize 让asSoundInsetsSpec=ASInsetLayoutSpecinsets:UIEdgeInsetsMake5,5,5,子对象:asSoundIcon 让asStackLayout=ASStackLayoutSpecdirection:。水平,间距:0,证明内容:。开始,对齐项目:。居中,子项:[asBackView,AssoundInsertSpec] 返回布局 } } p.S.布局SpecBlock在纹理>v上断裂。2.3.4

let asSoundLayout = ASStackLayoutSpec(direction: .horizontal, spacing: 0.0, justifyContent: .start, alignItems: .center, flexWrap: .noWrap, alignContent: .start, lineSpacing: 0.0, children: [asOverlayLayout, asSoundIcon])