- (void)layoutSubviews {
[super layoutSubviews];
NSArray <UILayoutGuide *> *array = barContentView.layoutGuides;
UILayoutGuide * backGuide;
UILayoutGuide * barGuide;
UILayoutGuide * itemGuide;
for (UILayoutGuide *obj in array) {
if ([obj.identifier hasPrefix:@"BackButtonGuide"]) {
backGuide = obj;
}
if ([obj.identifier hasPrefix:@"TrailingBarGuide"]) {
barGuide = obj;
}
if ([obj.identifier hasPrefix:@"UINavigationBarItemContentLayoutGuide"]) {
itemGuide = obj;
}
}
if (backGuide && barGuide && itemGuide) {
NSLayoutConstraint *left;
NSLayoutConstraint *rigth;
left = [backGuide.trailingAnchor constraintEqualToAnchor:itemGuide.leadingAnchor constant:10];
rigth = [barGuide.trailingAnchor constraintEqualToAnchor:itemGuide.trailingAnchor constant:-10];
left.active = YES;
rigth.active = YES;
}
}
网友评论