在UisearchBar中一直显示Xbutton

 
 UIButton *clearButton = [UIButton buttonWithType:UIButtonTypeCustom];
[clearButton setImage:img forState:UIControlStateNormal];[clearButton setFrame:frame];[clearButton addTarget:self action:@selector(clearTextField:) forControlEvents:UIControlEventTouchUpInside];textField.rightViewMode = UITextFieldViewModeAlways; //can be changed to UITextFieldViewModeNever, UITextFieldViewModeWhileEditing, UITextFieldViewModeUnlessEditing[textField setRightView:clearButton];
posted @ 2016-08-25 11:57  foolish_love  阅读(198)  评论(0)    收藏  举报