LoginSignup
0

More than 5 years have passed since last update.

[OSX][Swift]CATextLayer テキスト折り返し方法

Last updated at Posted at 2017-10-02

概要

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)!

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0