ios - How to distribute weights according to the width of UIView with Objective-C -


i'm trying linearlayout in ios, distribute weights depending layout. in case, i've got 4 views (3 uiview , 1 uilabel. scope giving same width of them depending superview's width, , set frame depending of it.

so in viewdidload execute command:

[self.view1 setframe:cgrectmake(0 * self.view1.superview.frame.size.width/4,                                 self.view1.frame.origin.y,                                 self.view.frame.size.width/4,                                 self.view1.superview.frame.size.height)];  [self.view2 setframe:cgrectmake(1 * self.view2.superview.frame.size.width/4,                                 self.view2.frame.origin.y,                                 self.view.frame.size.width/4,                                 self.view2.superview.frame.size.height)];  [self.view3 setframe:cgrectmake(2 * self.view3.superview.frame.size.width/4,                                 self.view3.frame.origin.y,                                 self.view.frame.size.width/4,                                 self.view3.superview.frame.size.height)];  [self.label setframe:cgrectmake(3 * self.label.superview.frame.size.width/4,                                 self.label.frame.origin.y,                                 self.view.frame.size.width/4,                                 self.label.superview.frame.size.height)]; 

but on iphone 6 get:

enter image description here

how you, guys, redistribute weights?

thank in advance.

rafael.


edit

i've discover calling super.view.frame.size.width doesn't give me full width... why ?

why don't use auto layout setting view1width equal container width multiplier 0.25 , other views

this link demonstrating how have propotional constraints

http://makeapppie.com/2014/11/25/proportional-sizes-in-autolayout/


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -