UITextField within UISearchBar in iOS 7

后端 未结 7 1672
北荒
北荒 2020-12-16 01:00

I am trying to accomplish the same look of my UISearchBar with a TextField within it, as in my iOS 6 app. I have tried to code it in several ways and not yet been successful

7条回答
  •  一生所求
    2020-12-16 01:11

    iOS6 & iOS7 compatible solution:

    - (void)setTextFieldAsDelegate:(UIView *)inputView {
        for (UIView *view in inputView.subviews) {
            if ([view isKindOfClass:[UITextField class]]) {
                searchBarTextField = (UITextField *)view;
                searchBarTextField.delegate = self;
                break;
            } else {
                [self setTextFieldAsDelegate:view];
            }
        }
    }
    

提交回复
热议问题