Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codeOfRobin
Created May 20, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeOfRobin/6b3db62719e2faf37a96142cf04c0d71 to your computer and use it in GitHub Desktop.
Save codeOfRobin/6b3db62719e2faf37a96142cf04c0d71 to your computer and use it in GitHub Desktop.
//
// TagNode.swift
// ChannelExample
//
// Created by Robin Malhotra on 24/04/18.
// Copyright © 2018 Robin Malhotra. All rights reserved.
//
import AsyncDisplayKit
class TagNode: ASCellNode {
let titleNode = ASTextNode()
init(title: String) {
super.init()
self.automaticallyManagesSubnodes = true
self.titleNode.attributedText = NSAttributedString(string: title, attributes: Styles.Text.tag)
}
override func didLoad() {
super.didLoad()
self.layer.cornerRadius = 4.0
self.clipsToBounds = true
self.layer.borderColor = UIColor(red:0.75, green:0.77, blue:0.78, alpha:1.00).cgColor
self.layer.borderWidth = 1.0
}
override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 4, left: 9, bottom: 4, right: 9), child: titleNode)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment