<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>tommy10344</author_name>
  <author_url>https://blog.hatena.ne.jp/tommy10344/</author_url>
  <blog_title>ttlog</blog_title>
  <blog_url>https://tommy10344.hatenablog.com/</blog_url>
  <categories>
    <anon>iOS</anon>
    <anon>Swift</anon>
  </categories>
  <description>iOSにおける文字列のサイズ取得方法のメモです。 Viewの横幅と比較して、1行に何文字表示出来るか等の計算が出来たりします。 文字列のサイズ取得 NSStringクラスにサイズが取得出来るメソッドがあるので、こちらを使います。 size(withAttributes:) UIFontを渡してあれば、フォントサイズに応じた文字列のサイズが取得出来ます。 // 今回はStringクラスのExtensionとして実装 import UIKit public extension String { public func size(with font: UIFont) -&gt; CGSize { let …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftommy10344.hatenablog.com%2Fentry%2F2018%2F08%2F15%2F140303&quot; title=&quot;iOS 文字列のサイズ取得方法 - ttlog&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/k/kurozu10344/20180815/20180815135537.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2018-08-15 14:03:03</published>
  <title>iOS 文字列のサイズ取得方法</title>
  <type>rich</type>
  <url>https://tommy10344.hatenablog.com/entry/2018/08/15/140303</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
