简体   繁体   中英

Navigation Item Swift 3 to Swift 4

The issue I've been having is that after I've downloaded Xcode 9, the user interface of my app has been messed up.

   let item1 = UIBarButtonItem(image: #imageLiteral(resourceName: "SettingsInto"), style: .done, target: self, action: #selector(settingsPressed))

    self.navigationItem.setRightBarButton(item1, animated: true)

    let item2 = UIBarButtonItem(image: #imageLiteral(resourceName: "search icon"), style: .plain, target: self, action: #selector(searchPressed))
    self.navigationItem.setLeftBarButtonItem(item2, animated: true)

    let imageButton = UIButton(frame: CGRect(x: 0, y: 0, width: 0, height: navigationBarHeight))
    let image = #imageLiteral(resourceName: "Stickiie Logo Main")
    imageButton.setImage(image, for: UIControlState())
    imageButton.imageView?.contentMode = .scaleAspectFit
    imageButton.addTarget(self, action: #selector(refresh), for: .touchDown)
    self.navigationItem.titleView? = imageButton

Before Xcode 9: 在此处输入图片说明

After Xcode 9: 在此处输入图片说明

Turns out, it was because the icon was too big.

https://developer.apple.com/ios/human-interface-guidelines/overview/themes/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM