ios - How can I apply multiplier to all my constraints created on nib files? -
i've pretty finished project, realize fonts , spaces in between weird in iphone 6plus.
i've created constraints drag , drop on xib files. colleague added these codes on global function can apply multipliers:
- (float)constraintscale { if (is_standard_iphone_6_plus) { return 1.29; } return 1.0;} - (float)textscale { if (is_standard_iphone_6_plus) { return 1.16; } return 1.0; }
my problem having drag each (more 100) constraints code , applying each these multiplier , scale. there more convenient way add multipliers xib files? i've thought subclassing take same amount of time?
self.view.constraints
will give constraints on view.
for(nslayoutconstraint *c in self.view.constraints) { c.multiplier = [self constraintscale]; }
probably work. hope helps.
edit: sorry readonly issue. way rid of problem may be;
nsmutablearray *constraintsnew = [nsmutablearray new]; (nslayoutconstraint *c in self.view.constraints) { nslayoutconstraint *newc = [nslayoutconstraint constraintwithitem:c.firstitem attribute:c.firstattribute relatedby:c.relation toitem:c.seconditem attribute:c.secondattribute multiplier:[self constraintscale] constant:c.constant]; [constraintsnew addobject:newc]; } [self.view removeconstraints:self.view.constraints]; [self.view addconstraints:constraintsnew];
Comments
Post a Comment