小程序畫布設(shè)置文字的豎直對齊
	   CanvasContext.setTextBaseline(string textBaseline)
設(shè)置文字的豎直對齊
基礎(chǔ)庫 1.4.0 開始支持,低版本需做兼容處理。
小程序插件:支持
參數(shù)
string textBaseline
文字的豎直對齊方式
textBaseline 的合法值
值    說明    最低版本
top    頂部對齊    
bottom    底部對齊    
middle    居中對齊    
normal        
示例代碼
const ctx = wx.createCanvasContext('myCanvas')
 
ctx.setStrokeStyle('red')
ctx.moveTo(5, 75)
ctx.lineTo(295, 75)
ctx.stroke()
 
ctx.setFontSize(20)
 
ctx.setTextBaseline('top')
ctx.fillText('top', 5, 75)
 
ctx.setTextBaseline('middle')
ctx.fillText('middle', 50, 75)
 
ctx.setTextBaseline('bottom')
ctx.fillText('bottom', 120, 75)
 
ctx.setTextBaseline('normal')
ctx.fillText('normal', 200, 75)
 
ctx.draw()
	   
 作者:大學(xué)生新聞網(wǎng)    來源:大學(xué)生新聞網(wǎng)