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
  • addTarget
  • Hit Test Slop
  • 터치영역 늘리기
  • 터치영역 줄이기

Was this helpful?

  1. Nodes

ASControlNode

PreviousASVideoNodeNextASScrollNode

Last updated 4 years ago

Was this helpful?

ASDisplayNode의 subClass이며, 사용자 인터렉션이 가능한 Node입니다.

Texture에서 제공되는 ASButtonNode, ASTextNode, ASMapNode, ASImageNode 등이 ASControlNode를 상속받고 있으며, 기본적으로 제공되는 ASControlNode subclass node이외 custom하게 터치가 가능한 Node를 만들 때 유용합니다.

UIKit의 UIControl과 마찬가지로 기본적인 Event를 아래와 같이 제공해줍니다.

/**
  @abstract Kinds of events possible for control nodes.
  @discussion These events are identical to their UIControl counterparts.
 */
typedef NS_OPTIONS(NSUInteger, ASControlNodeEvent)
{
  /** A touch-down event in the control node. */
  ASControlNodeEventTouchDown         = 1 << 0,
  /** A repeated touch-down event in the control node; for this event the value of the UITouch tapCount method is greater than one. */
  ASControlNodeEventTouchDownRepeat   = 1 << 1,
  /** An event where a finger is dragged inside the bounds of the control node. */
  ASControlNodeEventTouchDragInside   = 1 << 2,
  /** An event where a finger is dragged just outside the bounds of the control. */
  ASControlNodeEventTouchDragOutside  = 1 << 3,
  /** A touch-up event in the control node where the finger is inside the bounds of the node. */
  ASControlNodeEventTouchUpInside     = 1 << 4,
  /** A touch-up event in the control node where the finger is outside the bounds of the node. */
  ASControlNodeEventTouchUpOutside    = 1 << 5,
  /** A system event canceling the current touches for the control node. */
  ASControlNodeEventTouchCancel       = 1 << 6,
  /** A system event triggered when controls like switches, slides, etc change state. */
  ASControlNodeEventValueChanged      = 1 << 12,
  /** A system event when the Play/Pause button on the Apple TV remote is pressed. */
  ASControlNodeEventPrimaryActionTriggered = 1 << 13,

  /** All events, including system events. */
  ASControlNodeEventAllEvents         = 0xFFFFFFFF
};

addTarget

UIControl과 마찬가지로 addTarget에 대한 사용법은 동일합니다.

let node = ASControlNode()
node.addTarget(target: self, action: #selector(TODO:), for: .touchUpInside)

Hit Test Slop

터치영역을 조절하는 방식으로 두가지가 있습니다. UIKit와 동일하게 hitTest:withEvent:method를 override하는 방식과 hitTestSlop property를 접근해서 UIEdgeInsets을 negative or positive 값을 적절히 지정하는 방식이 있습니다.

hitTestSlop property접근을 활용한 조절을 권장합니다.

터치영역 늘리기

let node = ASControlNode()
// negative -> 터치영역 증
node.hitTestSlop = .init(top: -100.0, left: -100.0, bottom: -100.0, right: -100.0)

터치영역 줄이기

let node = ASControlNode()
// positive -> 터치영역 감소 
node.hitTestSlop = .init(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)

조절한 Hit Test Slop을 Visualization하는 방법은 를 참고해주세요.

여기