How can I move the clear button in a UITextField?

前端 未结 7 1584
既然无缘
既然无缘 2021-02-13 13:14

For some reason, when I add a UITextfield as a subview of the contentview of a tablecell, the clearbutton does not align with the text typed in the field, and appears a bit unde

7条回答
  •  醉话见心
    2021-02-13 13:38

    Subclass UITextField and override this method:

    - (CGRect)clearButtonRectForBounds:(CGRect)bounds
    {
        return CGRectMake(bounds.origin.x - 10, bounds.origin.y, bounds.size.width, bounds.size.height);
    }
    

    return the CGRect that matches your needs.

提交回复
热议问题