ios - Autoresize subviews when resizing the superview -


i not able handle subview resizing correctly:

suppose have custom uiview class, inside contains uiimageview.

initially, set uiviews followings:

// width , height uiimage width height // possible uiimage width height larger 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() 

let's call custom uiview myview.

and when want place "myview" in viewcontroller. did followings:

myview.frame = cgrectmake(xpos, ypos, 100, 100) myview.autoresizesubviews = true 

and found after did this, got following results. myview place @ correct place correct size, internal uiimageview got smaller size.

why happen? , how make subviews inside myview resize correctly according frame of myview?

thanks.

oh, found autoresizing mask should set follows:

self.imageview.autoresizingmask = [.flexiblewidth, .flexibleheight, .flexiblerightmargin, .flexiblebottommargin] 

this allows anchor fixed @ top , left, , allow resizing on other margins.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -