[英]iOS 11 Navigationbar icon issue
iOS 11 導航問題我需要在導航欄上設置左右和標題視圖
這是這樣,但現在我有問題:
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;
對象-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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.