Set text style attributes(텍스트 스타일 속성 설정)

Set text style attributes
(텍스트 스타일 속성 설정)

In some of our projects, the text will be used frequently, which is inevitably to set the font size, font color, text content, etc…
(일부 프로젝트에서는 텍스트가 자주 사용되어 글꼴 크기, 글꼴 색, 텍스트 내용 등을 필연적으로 설정합니다.)
Let’s start with a basic demo to create a text, add text content and set the font color (background default color is black).
(텍스트를 만들고 텍스트 내용을 추가하고 글꼴 색상을 설정하는 데 필요한 기본 데모부터 시작해 봅니다 (배경 기본 색상은 검은 색입니다).)
Laya.display.text set text style with API parameters:
(Laya.display.text는 API 매개 변수로 텍스트 스타일을 설정합니다.)
1
2
  1. //初始化引擎(엔진 초기화)
  2. Laya.init(1136,640);
  3. var txt = new Laya.Text();
  4. //设置文本内容(텍스트 콘텐츠 설정)
  5. txt.text = "hello_world";
  6. //设置文本颜色(텍스트 색상 설정)
  7. txt.color = "#ffffff";
  8. Laya.stage.addChild(txt);
At this point, we can see that txt has been added to the stage, showing hello_world in white.
(이 시점에서 텍스트가 무대에 추가되어 hello_world가 흰색으로 표시됨을 알 수 있습니다.)
Now we add some other font styles to our text, such as bold, italic, and font size.
(이제 텍스트에 굵게, 기울임 꼴 및 글꼴 크기와 같은 다른 글꼴 스타일을 추가합니다.)
3
4
  1. //初始化引擎(엔진 초기화)
  2. Laya.init(1136,640);
  3. var txt = new Laya.Text();
  4. //设置文本内容(텍스트 콘텐츠 설정)
  5. txt.text = "hello_world";
  6. //设置文本颜色(텍스트 색상 설정)
  7. txt.color = "#ffffff";
  8. //设置文本字体(텍스트 글꼴 설정)
  9. txt.font = "Ya Hei";
  10. //设置字体大小(글꼴 크기 설정)
  11. txt.fontSize = 32;
  12. //设置文本区背景(텍스트 영역 배경 설정)
  13. txt.bgColor = "#c30c30";
  14. //设置文本框的颜色(텍스트 상자의 색상 설정)
  15. txt.borderColor = "#23cfcf";
  16. //设置粗体、斜体(굵게, 기울임 꼴로 설정)
  17. txt.bold = true;
  18. //设置斜体(기울임 꼴 설정)
  19. txt.italic = true;
  20. Laya.stage.addChild(txt);
5
Here we can see the font style, the font size has obviously and other details changes.
(여기에서 우리는 글꼴 스타일을 볼 수 있습니다. 글꼴 크기는 분명히 다른 세부 사항을 변경했습니다.)

댓글 없음:

댓글 쓰기