0
我正在使用以下代碼創建帶有清除按鈕模式的文本字段。UITextField「clearButtonRectForBounds」方法不調用
self.TextField =[[UITextField alloc]initWithFrame:CGRectMake(30, 0, 200, 30)];
self.TextField.tintColor =[UIColor lightGrayColor];
self.TextField.returnKeyType =UIReturnKeyGo;
self.TextField.clearButtonMode =UITextFieldViewModeWhileEditing;
self.TextField.delegate=self;
[self.view addSubview:self.TextField];
- (CGRect)clearButtonRectForBounds:(CGRect)bounds
{
return CGRectMake(bounds.origin.x - 10, bounds.origin.y, bounds.size.width, bounds.size.height+30);
}
我想爲清除按鈕設置自定義框架,爲此我試圖調用「clearButtonRectForBounds」。但「clearButtonRectForBounds」方法不能調用。我如何設置清晰的按鈕框架?
我有一個UIViewController subclass.In該類我有一個文本字段 – lazyCoder
歐凱,但你已經創建了一個UITextField的子類,然後在你的UIViewController中使用。 – Hemang