ios - How to change the position of the button through coding xcode -
i trying align button created through code, can't seem change position, code:
- (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { self.backgroundcolor = [uicolor whitecolor]; self.linewidth = default_width; self.linecolor = default_color; uibutton* btn = [uibutton buttonwithtype:uibuttontyperoundedrect]; btn.frame = cgrectmake(20,100, 50, 50); //[btn setframe:cgrectmake(3,20, 50, 50)]; btn.center = self.center; [btn settitle:@"clear" forstate:uicontrolstatenormal]; [btn addtarget: self action: @selector(clearbuttonpressed:) forcontrolevents: uicontroleventtouchdown]; [self addsubview:btn]; } return self; } if remove "btn.center =self.center" , try set x , y position as
"btn.frame =cgrectmake(3,20,50,50)" it doesn't display button. please appreciated , in advance!
have tried using [btn setcenter:center]; center cgpoint?
Comments
Post a Comment