2021-07-22
2023-09-27 本文已影响0人
ping_oO
- (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;
}
}