I want to add a UITextField to the UITooolbar and let the UITextField expand its width as needed to fill an area like UIBarButtonSystemItemFlexibleSpace.
The following is a snippet of how I usually customized toolbar items in the view controller ...
UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:nil action:nil];
UITextField *textField = [[UITextField alloc] init];
textField.borderStyle = UITextBorderStyleRoundedRect;
UIBarButtonItem *text = [[UIBarButtonItem alloc] initWithCustomView:textField];
[self setToolbarItems:@[left, text, right]];
... which will then be displayed as follows.

, iOS 11 UIToolbar layoutSubviews (CGRectGetWidth(itemView.frame)
) "" .
iOS 11 Apple , WWDC2017 session 204, CGRectGetWidth(itemView.frame)
, , iOS 11 UIBarButtonItem .
UIBarButtonItems customViews , , ?
1:
, , .

2:
UIToolbar , ( ?) .
UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIView *leftView = [left valueForKey:@"view"];
UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:nil action:nil];
UIView *rightView = [right valueForKey:@"view"];
UITextField *textField = [[UITextField alloc] init];
textField.borderStyle = UITextBorderStyleRoundedRect;
UIBarButtonItem *text = [[UIBarButtonItem alloc] initWithCustomView:textField];
NSDictionary *views = NSDictionaryOfVariableBindings(leftView, textField, rightView);
NSString *formatString = @"|-[leftView]-[textField]-[rightView]-|";
NSArray *constraint = [NSLayoutConstraint constraintsWithVisualFormat:formatString options:NSLayoutFormatAlignAllCenterX metrics:nil views:views];
[NSLayoutConstraint activateConstraints:constraint];
[self setToolbarItems:@[left, text, right]];
3:
UIToolbar ...
UIView *contentView = nil;
for (UIView *view in self.navigationController.toolbar.subviews) {
if ([view.description containsString:@"ContentView"]) {
contentView = view;
}
}
UIView *stackView = nil;
for (UIView *view in contentView.subviews) {
if ([view.description containsString:@"ButtonBarStackView"]) {
stackView = view;
}
}
UIView *uiButtonBarButton = [stackView.subviews objectAtIndex:0];
[uiButtonBarButton.leadingAnchor constraintEqualToAnchor:stackView.leadingAnchor].active = YES;
UIView *uiTAMICAdaptorView = [stackView.subviews objectAtIndex:2];
[uiTAMICAdaptorView.leadingAnchor constraintEqualToAnchor:uiButtonBarButton.trailingAnchor].active = YES;
[uiTAMICAdaptorView.trailingAnchor constraintEqualToAnchor:stackView.trailingAnchor].active = YES;
... :

UIBarButton , UITextField aka UITAMICAdaptorView?
UIBarButton ...
[uiButtonBarButton.widthAnchor constraintEqualToConstant:CGRectGetWidth(uiButtonBarButton.frame)].active = YES;
... ...

... , , UIButtonBarButton , .
, UIButtonBarButton , . - "notGreaterThanNecessary"?