概要
CATextLayerを使ってのテキストの折り返しにハマったので自分用のメモ。
内容
生成したCATextLayerのプロパティ isWrappedをtrueに設定すると折り返しされる。
サンプルコード
CATextLayer_sample.swift
let textLayer = CATextLayer()
textLayer.string = attrString
textLayer.font = font
textLayer.fontSize = font.pointSize
textLayer.foregroundColor = NSColor.black.cgColor
textLayer.frame = myFrame
textLayer.isWrapped = true // isWrappedをtrueに
textLayer.contentsScale = (NSScreen.main()?.backingScaleFactor)!