ios - UITextField overflow -


i made simple subclass uitextfield , works intended. problem i'm encountering when text value gets large, overflows clear button.

enter image description here

i can't seem find out how alter right side of text have padding not intersect clear button.

#import "textfield.h" #import <quartzcore/quartzcore.h>  ib_designable  @implementation textfield  - (void)awakefromnib {     self.layer.bordercolor = [[[uicolor graycolor] colorwithalphacomponent:0.5] cgcolor];     [self.layer setborderwidth:0.6];     self.layer.cornerradius = 4;     self.layer.maskstobounds = yes; }  - (cgrect)textrectforbounds:(cgrect)bounds {     return cgrectinset(bounds, 12, 0); }  - (cgrect)editingrectforbounds:(cgrect)bounds {     return [self textrectforbounds:bounds]; }  @end 

i've managed move both sides of text doesn't overflow button, left side looks strange because has spacing. how can add padding right side of text or left side of clear button?

just shift rect on bit.

- (cgrect)textrectforbounds:(cgrect)bounds {     return cgrectmake(bounds.origin.x, bounds.origin.y, bounds.size.width - 10, bounds.size.height); } 

by extension editing rect should update since you're basing off textrect.


Comments