Texture Guide (한국어)
  • Texture-kr에 오신것을 환영합니다.
  • Intro
    • 국내 Texture 도입사례
    • 유용한 라이브러리 소개
    • 유용한 글 모음
  • Newbie Guide
    • Node?
    • LayoutSpec?
    • Flex Box
    • Intelligent Preloading
    • Quick Example
  • Nodes
    • ASDisplayNode
    • ASCellNode
    • ASButtonNode
    • ASTextNode
    • ASTextNode2
    • ASImageNode
    • ASNetworkImageNode
    • ASVideoNode
    • ASControlNode
    • ASScrollNode
    • ASEditableTextNode
  • Node Containers
    • ASDKViewController
    • ASViewController (DEPRECATED)
    • ASNodeController (Beta)
    • ASTableNode
    • ASCollectionNode
    • ASPagerNode
  • Layout API
    • Layout Element Properties
    • LayoutSpecs
    • Layout API Sizing
    • Layout Transition API
  • Optimizations
    • Layer Backing
    • Corner Rounding
  • Threading
    • Threading
  • Advanced guide
    • Debug Tool
    • Accessibility
    • Tips
  • Cookbook
    • Intro
Powered by GitBook
On this page
  • 기본 사용법
  • 상태 제어
  • Target-Action Pairs
  • 컨텐츠 정렬
  • tintColor 설정

Was this helpful?

  1. Nodes

ASButtonNode

기본 사용법

ASButtonNode 는 UIButton 이 UIControl 의 서브 클래스인 것 처럼 ASControlNode 의 서브 클래스입니다. UIButton 과 다르게 버튼의 모든 서브노드들을 Layer back 할 수 있는건 Main thread Impact 를 상당히 가볍게 할 수 있습니다.

상태 제어

기존에 setTitle(_:for:) 를 사용해 봤다면 ASButtonNode 도 동일하게 사용할 수 있습니다. ASButtonNode 는 속성을 쉽게 세팅하기 위해서 몇가지 매개변수를 추가했습니다.

buttonNode.setTitle("Button Title Normal", with: nil, with: .blue, for: .normal)

더 많은 제어가 필요하다면 AttributeString 을 직접 사용하도록 선택할 수 있습니다.

buttonNode.setAttributedTitle(attributedTitle, for: .normal)

Target-Action Pairs

UIKit 과 마찬가지로, 다양한 이벤트에 반응하기 위해 target-action pairs 를 추가할 수 있습니다.

buttonNode.addTarget(self, action: #selector(buttonPressed), forControlEvents: .touchUpInside)

컨텐츠 정렬

ASButtonNode 는 contentVerticalAlignment 와 contentHorizontalAlignment 프로퍼티를 제공합니다. 이 프로퍼티를 사용하면 버튼에 사용중인 타이틀과 이미지의 정렬을 쉽게 설정할 수 있습니다.

buttonNode.contentVerticalAlignment = .top
buttonNode.contentHorizontalAlignment = .middle

현재 LayoutSpecThatFits(:) 를 사용하지 않으면 이 프로퍼티가 정상 작동하지 않습니다.

tintColor 설정

ASButtonNode 에서 tintColor 값을 변경해도 이미지의 컬러가 변하지 않습니다. 아래의 코드를 사용해서 이미지의 컬러를 변경해주세요.

buttonNode.imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.black)
PreviousASCellNodeNextASTextNode

Last updated 4 years ago

Was this helpful?