Git Product home page Git Product logo

asdk_demo's Introduction

ASDK_demo

This is a demo about how to use ASDK(AsyncDisplayKit / Texture) 中文介绍

stack spec

Overview

  • ASImageNode
  • ASTextNode
  • ASButtonNode
  • ASTableNode
  • ASCollectionNode

Layout

  • Inset
  • Stack
  • Relative & center
  • Ratio
  • Overlay & background
  • Absolute

Games

  • Waiting

colleciton node

asdk_demo's People

Contributors

ashen-23 avatar

Stargazers

 avatar  avatar  avatar

Forkers

changzw

asdk_demo's Issues

Round corner ASCellNode

Could you please help me.
I have ASCellNode
This cell should be present, an array of ASDisplayNode(contentNodes) in an ASStackLayoutSpec I want to make the ASStackLayoutSpec rounded corner, I tried lots of different approaches, but I can't, are you have some advice?
for example, I used ASBackgroundLayoutSpec with a background bubble, but it doesn't worked!

import Foundation
import AsyncDisplayKit

public class CardCellNode: ASCellNode {
    
    
    let contentNodes: [CardContentNode]
    private let card: Card
    private let bubbleNode = ASImageNode()

    init(card: Card, contentNodes: [CardContentNode]) {
        
        
        
        self.contentNodes = contentNodes
        self.card = card
        super.init()
        for contentNode in contentNodes {
            addSubnode(contentNode)
            
        }
        self.style.flexGrow = 1.0
        self.style.flexShrink = 1.0
        selectionStyle = .none
        
        bubbleNode.image = R.image.bubble()
        bubbleNode.style.flexShrink = 1
        
//        addSubnode(bubbleNode)
    }
    
    public override func didLoad() {
        super.didLoad()
        for contentNode in contentNodes {
            contentNode.backgroundColor =  card.backgroundColor.hasPrefix("#") ? UIColor(hexString: card.backgroundColor) : .white
            
//            contentNode.cornerRadius = 10
            isUserInteractionEnabled = true
        }
        
    }
    
    public override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
        let contentVerticalStack = ASStackLayoutSpec.vertical()
        contentVerticalStack.style.flexShrink = 1.0
        contentVerticalStack.style.flexGrow = 1.0
        contentVerticalStack.style.spacingAfter = 5.0
        contentVerticalStack.style.spacingBefore = 5.0
        contentVerticalStack.children = contentNodes
        
        
        
        let contentSpec = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10), child: contentVerticalStack)
        
        return contentSpec
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.