私はあなたのビューのソースをGoogleで検索してGitHubでそれを見つけました。
- (CGSize)intrinsicContentSize
{
// Default to let UIImageView handle the sizing of its image, and anything else it might consider.
CGSize intrinsicContentSize = [super intrinsicContentSize];
// If we have have an animated image, use its image size.
// UIImageView's intrinsic content size seems to be the size of its image. The obvious approach, simply calling `-invalidateIntrinsicContentSize` when setting an animated image, results in UIImageView steadfastly returning `{UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric}` for its intrinsicContentSize.
// (Perhaps UIImageView bypasses its `-image` getter in its implementation of `-intrinsicContentSize`, as `-image` is not called after calling `-invalidateIntrinsicContentSize`.)
if (self.animatedImage) {
intrinsicContentSize = self.image.size;
}
return intrinsicContentSize;
}
animatedImageの場合にはサイズが元の画像サイズに縮小されるであろうと思わ: 実装に見た後、私は次のコードを発見しました。
リンゴのドキュメントは、固有のコンテンツサイズについて伝えます:一般的に
、本来のコンテンツサイズを使用すると、これは本質的な内容として解釈することができ
を必要とする制約の数を減らし、レイアウトを簡素化サイズの使用法はすでにサイズの制約を追加しています。本来のコンテンツサイズの使用に関する詳細情報については以下を参照してください
override var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: UIViewNoIntrinsicMetric)
}
をところで:(いくつかの副作用があるかどうかわからない)Apple Documentationが
一つの解決策は、そのように固有のコンテンツのサイズをオーバーライドするサブクラスを使用するようになります。次の質問の情報源へのリンクを提供してください。それは、それを探し出す時間を節約します。ありがとう!