# Storyboard

## มารู้จักกับ Storyboard กัน

ในการจัดการหน้าจอเราสามารถใช้ได้ทั้งโค้ด หรือ storyboard ก็ได้ โดยโปรเจคที่เราทำกันเราจะใช้ storyboard ในการจัดการหน้าจอเป็นหลัก

ให้เรากดเลือกไฟล์ **Main.storyboard** ส่วน editor จะแสดงดังรูป

![](/files/BBEDPJ54Pcn2ejWWz7I6)

ด้านซ้ายจะเป็น **document outline** แสดงโครงสร้างลำดับชั้นของ View ต่าง ๆ ที่เราใส่ลงไปในแต่ละหน้าจอ&#x20;

ในตัวอย่างจะเป็นหน้า View Controller มี View หลัก 1 อัน (ที่ไฮไลท์สีน้ำเงิน)

![Document outline](/files/u5GWejTEOOcMcJTjzbiS)

ด้านขวาจะเป็น **Utility panel** แบ่งเป็นกลุ่ม ๆ มี 7 กลุ่ม เราจะใช้ 4 อันหลังเป็นหลัก ได้แก่

1. **Identity inspector** ใช้กำหนด class ของ view
2. **Attributes inspector** ใช้กำหนดค่าต่าง ๆ ของ view เช่น สี background, ฟอนต์
3. **Size inspector** ใช้กำหนดขนาด และจัด Auto layout
4. **Connection inspector** ใช้ดูการเชื่อมโยงของ view กับ controller

![Attributes Inspector](/files/hyXpIvy1RjvhZQfzK3h3)

เหนือขึ้นด้านบนจะมีปุ่ม + อยู่สำหรับเรียกเปิด **Object Library**&#x20;

**Object Library** เป็นคลังของ view ต่าง ๆ ที่ iOS มีให้เราใช้ เช่น Label, TextField, Button เป็นต้น

![](/files/lsbkwXi4VqF4A0P2aHbB)

ด้านล่างสุดกลางจอ มี shortcut ต่าง ๆ เมื่อกดด้านซ้ายเปิดขึ้นมาเราสามารถจำลองขนาดของหน้าจอต่าง ๆ ให้กับ storyboard ได้ ส่วนทางด้านขวาเป็น shortcut ในการจัด alignment หรือเพิ่ม Auto layout&#x20;

![หน้าจอขนาดต่าง ๆ](/files/HwN3kfd2GTXyJaNspq3y)


---

# 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://pakornpat.gitbook.io/ios-app/storyboard.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.
