Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import AsyncDisplayKit
  2.  
  3. class ActionNode: ASDisplayNode {
  4.  
  5. // MARK: - Nodes
  6.  
  7. private let loveButton: ASImageNode
  8. private let commentButton: ASImageNode
  9. private let shareButton: ASImageNode
  10.  
  11. override init() {
  12. self.loveButton = ASImageNode()
  13. loveButton.image = imageLiteral(resourceName: "love")
  14. loveButton.style.preferredSize = CGSize(width: 16, height: 16)
  15.  
  16. self.commentButton = ASImageNode()
  17. commentButton.image = imageLiteral(resourceName: "comment")
  18. commentButton.style.preferredSize = CGSize(width: 16, height: 16)
  19.  
  20. self.shareButton = ASImageNode()
  21. shareButton.image = imageLiteral(resourceName: "share")
  22. shareButton.style.preferredSize = CGSize(width: 16, height: 16)
  23.  
  24. super.init()
  25.  
  26. self.automaticallyManagesSubnodes = true
  27. }
  28.  
  29. override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
  30. let mainStack = ASStackLayoutSpec(direction: .horizontal,
  31. spacing: 16,
  32. justifyContent: .start,
  33. alignItems: .start,
  34. children: [loveButton,commentButton, shareButton])
  35.  
  36. let padding = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), child: mainStack)
  37.  
  38. return padding
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement