美文网首页
2021-07-22

2021-07-22

作者: ping_oO | 来源:发表于2023-09-27 08:50 被阅读0次
    - (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;
         }
    }
    

    相关文章

      网友评论

          本文标题:2021-07-22

          本文链接:https://www.haomeiwen.com/subject/jfgemltx.html