i have subclassed uiview , created few views inside it. want create instance of view inside view controller's view , there's custom view placed below view. not sure how put second view below first view.
when debug frames, {{0,0}, {0,0}}. using masonry view layout. have tried several solutions this thread
i have created sample project has actual code have tried. https://github.com/anuj-rajput/viewsample
in sample project, there 2 subclasses of uiview
, phoneverificationtopview
, phoneverificationphonenumberview
, view controller phoneverificationviewcontroller
creates objects both these views. need order them in such way aligned vertically (phonenumberview
below topview
).
am doing wrong? there right way subclass uiview , refer in controller?
this how view should like
when using autolayout, , want parent view resize according i'ts subclasses, needed know how big content is.
the top view has have constraint top of parent view. , bottom view has have constraint bottom of parent view.
currently views acutely not containing there subclasses.
if try, instance set background color of "topview" red, notice, not change i'ts color. because i'ts size 0. i'ts not wrapping i'ts content. if set "cliptobound" yes, not see subclasses too.
to fix it, add bottom constraint, bottom view parent view:
[self.subtitletextlabel mas_makeconstraints:^(masconstraintmaker *make) { make.centerx.equalto(self.titletextlabel); make.width.equalto(self.mas_width).multipliedby(0.7); make.top.equalto(self.titletextlabel.mas_bottom).with.offset(10.f); make.bottom.equalto(self.mas_bottom); //this line added }]; [self.sendbutton mas_makeconstraints:^(masconstraintmaker *make) { make.centerx.equalto(self); make.width.equalto(self).multipliedby(0.4); make.height.equalto(@40); make.top.equalto(self.phonenumbertextview.mas_bottom).with.offset(30.f); make.bottom.equalto(self.mas_bottom); // line added }];
Comments
Post a Comment