ios - Problems with getting right cornerRadius for a different size of the screen -
i have problem application.
in want have 12 round buttons choosing color. used iubutton this. used auto layout constrains the app same on different sizes of iphone screen. , here face problem:
when select in simulated metrics in ib "inferred" size of screen, 4 inch screen has circle button.other, bigger iphone sizes showing rectangle buttons rounded corners.
it looks button resized still using smaller cornerradius(of 4 inch iphone), though width , height have changed.
but when choose same size in simulated metrics , in simulator have desired result.
and have no idea that! here part of code using make circle buttons. hope help! hope not duplicate.
in other words if don't choose view in metric size rounded corners, not circles. if choose same size iphone in simulator fine (as needed). need have circles while metrics size set inferred.
here part of code using:
- (void)viewdidload { [super viewdidload]; } -(void)viewwilllayoutsubviews { [super viewwilllayoutsubviews]; self.iscurrencyselect = no; [self createcardtypelist]; self.currencylist = [financeutils currencycodelistwithappendedname:no]; self.pickercontainerview.hidden = yes; [self.cardtypebutton settitle:cardtypename forstate:uicontrolstatenormal]; [self.currencybutton settitle:cardcurrencyname forstate:uicontrolstatenormal]; self.cardbackgroundview.layer.cornerradius = 10.0f; self.cardbackgroundview.layer.borderwidth = 2.0f; self.cardbackgroundview.layer.bordercolor = [uicolor blackcolor].cgcolor; self.cardbackgroundview.backgroundcolor = [uicolor colorfromhexstring:@"#502ca7"]; //change placeholder color [self.cardnametextfield setvalue:[uicolor darkgraycolor] forkeypath:@"_placeholderlabel.textcolor"]; [self.incometextfield setvalue:[uicolor darkgraycolor] forkeypath:@"_placeholderlabel.textcolor"]; //set cards value self.moneyspentvaluelabel.text = @"0"; } -(void) viewwillappear:(bool)animated{ [super viewwillappear:animated]; [self updatebuttonscolor]; } -(void) updatebuttonscolor{ nsarray *buttonscolorarray = [uicolor cardscolorarray]; for(uibutton *btn in self.buttonsarray){ btn.layer.borderwidth = 2.0f; btn.layer.cornerradius = btn.frame.size.width/2; btn.layer.maskstobounds = yes; btn.backgroundcolor = [buttonscolorarray objectatindex:btn.tag]; } }
the corner radius should not constant, try changing button height or that.
Comments
Post a Comment