2017-10-12 5 views
0

UIViewController의 탐색 막대 오른쪽에 두 개의 UIButton이 있습니다. UIbutton에는 이미지가 있습니다. 응용 프로그램은 Xcode 8에서 실행될 때까지 제대로 작동하지만 Xcode 9를 업데이트하면 렌더링되지 않고 전체 탐색 모음을 사용하고 있습니다. 엑스 코드 (8) 그것은 enter image description hereXcode 9로 업데이트 한 후 탐색 바 버튼의 이미지가 렌더링되지 않음

했지만, 엑스 코드 9로 업데이트 한 후에는

func setUpNavBar(){ 
    self.navigationController?.navigationBar.isTranslucent = false 
    self.navigationItem.setHidesBackButton(true, animated: true) 


    let notificationBtn = UIButton(type: .custom) 
    notificationBtn.setImage(UIImage(named: "notificationIcon"), for: .normal) 
    notificationBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35) 
    notificationBtn.addTarget(self, action: #selector(HomeViewController.notificationClicked), for: .touchUpInside) 
    let item1 = UIBarButtonItem(customView: notificationBtn) 

    let profileBtn = UIButton(type: .custom) 
    profileBtn.setImage(UIImage(named: "user_profile"), for: .normal) 
    profileBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35) 
    profileBtn.addTarget(self, action: #selector(HomeViewController.ProfileClicked), for: .touchUpInside) 
    let item2 = UIBarButtonItem(customView: profileBtn) 
    self.navigationItem.setRightBarButtonItems([item1,item2], animated: true) 

} 

정말입니다 ... 네비게이션 바 설정하는 것은이

enter image description here

내 코드처럼 보인다 그것이 왜 일어나고 있는지 혼란스러워합니다. iOS 11에서

답변

2

당신은/높이의 세트 제약 조건을 추가하고 를 들어 UIButton

let widthConstraint = notificationBtn.widthAnchor.constraint(equalToConstant: 35) 
let heightConstraint = notificationBtn.heightAnchor.constraint(equalToConstant: 35) 
heightConstraint.isActive = true 
widthConstraint.isActive = true 

notificationBtn하는 것은 너무 profileBtn에 대한 동일 적용으로해야합니다.

+0

나는 당신이 중복으로 마크해야한다고 생각한다. –

+1

그것은 고마워 남자 다. – Prathamesh