# ASButtonNode

## 기본 사용법

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

## 상태 제어

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

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

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

```swift
buttonNode.setAttributedTitle(attributedTitle, for: .normal)
```

## Target-Action Pairs

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

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

## 컨텐츠 정렬

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

```swift
buttonNode.contentVerticalAlignment = .top
buttonNode.contentHorizontalAlignment = .middle
```

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

## tintColor 설정

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

```swift
buttonNode.imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.black)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://texture-kr.gitbook.io/wiki/nodes/asbuttonnode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
