2017-09-25 14 views
-1

How to set Left/Right and title view (OBJC)iOSの11 Navigationbarアイコンの問題

iOSの11ナビゲーションの問題は、私は、ナビゲーションバー

  1. これは私の現在のコードである上、左、右とタイトルビューを設定する必要があります。
  2. だから、これはですが、今私はそれで問題がある:

    btnMenu = [UIButton buttonWithType:UIButtonTypeSystem]; 
        [btnMenu setFrame:CGRectMake(0, 0, 25, 25)]; 
        [btnMenu setTintColor:[UIColor blackColor]]; 
        [btnMenu setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; 
        [btnMenu setImage:[UIImage imageNamed:@"menu"] forState:UIControlStateNormal]; 
        [btnMenu addTarget:self action:@selector(clickOnMenu:) forControlEvents:UIControlEventTouchUpInside]; 
    
        leftBarButton2 = [[UIBarButtonItem alloc] initWithCustomView:btnMenu]; 
    
        [arrLeftBarButton addObject:leftBarButton2]; 
    
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithArray:arrLeftBarButton]; 
    
    
    [viewTitle addSubview:search]; 
    [viewTitle addSubview:btnSelectSearch]; 
    viewTitle.translatesAutoresizingMaskIntoConstraints = false; 
    
    self.navigationItem.titleView = viewTitle; 
    
    BBBadgeBarButtonItem *badgeNotify = [[BBBadgeBarButtonItem alloc] initWithCustomUIButton:btnNotify]; 
    badgeNotify.badgeBGColor = [UIColor whiteColor]; 
    badgeNotify.badgeTextColor = [UIColor blackColor]; 
    badgeNotify.badgeValue = @"0"; 
    
    self.navigationItem.rightBarButtonItem = badgeNotify; 
    
+0

が見るこのhttps://でのstackoverflow .com/questions/44442573/navigation-bar-rightbaritem-image-button-bug-ios-11 –

+0

それはナビゲーションバーの推奨サイズではない画像を設定しているようです。ヒューマンインタフェースのガイドラインを見てください:https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/custom-icons/ PS:コードを投稿できる方が簡単になります。実際の問題を指摘することができるように – Rishi

答えて

0

のObj-C

NSLayoutConstraint * widthConstraint = [btnMenu.widthAnchor constraintEqualToConstant:25]; 
NSLayoutConstraint * heightConstraint =[btnMenu.heightAnchor constraintEqualToConstant:25]; 
[widthConstraint setActive:YES]; 
[heightConstraint setActive:YES]; 

UIBarButtonItem* btnMenuItem = [[UIBarButtonItem alloc] initWithCustomView: btnMenu]; 
self.navigationItem.leftBarButtonItem = btnMenuItem; 

スウィフト

let widthConstraint = button.widthAnchor.constraint(equalToConstant: 25) 
let heightConstraint = button.heightAnchor.constraint(equalToConstant: 25) 
heightConstraint.isActive = true 
widthConstraint.isActive = true 
関連する問題