客户端 API/工作台小组件/工作台小组件 API/画布（灰度租户可见）/CanvasContext/CanvasContext.setTextBaseline
# CanvasContext.setTextBaseline

## CanvasContext.setTextBaseline('top' | 'middle' | 'bottom' | 'normal' textBaseline)

设置文字垂直方向的对齐方式。

## 参数说明

|**属性**|**类型**|**默认值**|**必填**|**说明**|**最低版本**
|:-|:-|:-|:-|:-|:-|
|textBaseline|'top' \| 'middle' \| 'bottom' \| 'normal"'|-|是|垂直方向的对齐方式|1.6.0

## 返回值

无

## 示例

### 示例代码

```javascript
const ctx = tt.createCanvasContext("canvas");

const textBaselineList = ["top", "middle", "bottom", "normal"];

ctx.strokeStyle = "red";
ctx.moveTo(5, 75);
ctx.lineTo(295, 75);
ctx.stroke();
ctx.font = "20px sans-serif";

for (let i = 0; i < textBaselineList.length; ++i) {
  ctx.setTextBaseline(textBaselineList[i]);
  ctx.fillText(textBaselineList[i], 5 + 70 * i, 75);
}

ctx.draw();
```

### 示例效果

## Tip
无
