のサイズを変更する際、私は正しくリサイズサブビューを処理することはできませんよ。自動サイズ変更サブビュースーパー
それはUIImageViewが含まれている内部の私は、カスタムUIViewクラスを持っていると仮定します。
は当初、私は以下のようなUIViewsを設定します。
// width and height are UIImage width height
// it is possible that the UIImage width height is larger than the container
self.imageView.frame = CGRectMake(0 ,0, width, height)
self.imageView.backgroundColor = UIColor.redColor()
self.imageView.contentMode = UIViewContentMode.ScaleAspectFit
self.imageView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight,.FlexibleTopMargin, .FlexibleLeftMargin, .FlexibleRightMargin, .FlexibleBottomMargin]
addSubview(self.imageView)
self.frame = CGRectMake(0, 0, width, height)
self.backgroundColor = UIColor.greenColor()
はのはMYVIEWとしてこのカスタムUIViewのを呼ぶことにしましょう。
そして、この "myView"をViewControllerに配置したいとき。私は次のことをしました:
myView.frame = CGRectMake(xPos, yPos, 100, 100)
myView.autoResizeSubviews = true
そして私はこれを行った後、次の結果を得ました。 MyView place at the correct place with correct size, but the internal UIImageView got even a smaller size.
なぜですか。 MyView内のすべてのサブビューをMyViewのフレームに従って正しくサイズ変更するにはどうすればよいですか?
ありがとうございました。