导航项中的标题视图不';不考虑IOS 11的帧高度
我已经更新到了Xcode 9,在我的导航项中的标题视图不';不考虑IOS 11的帧高度,ios,swift,xcode,swift3,Ios,Swift,Xcode,Swift3,我已经更新到了Xcode 9,在我的导航项中有一个标题视图,创建方式如下: let logo = UIImageView(frame: CGRect(x: 0, y: 0, width: 70, height: 25)) logo.image = UIImage.logo logo.contentMode = .scaleAspectFit self.navigationItem.titleView = logo 结果是,它不再考虑帧的高度。 我们可以控制UINavigationbar标题视图
导航项中有一个标题视图
,创建方式如下:
let logo = UIImageView(frame: CGRect(x: 0, y: 0, width: 70, height: 25))
logo.image = UIImage.logo
logo.contentMode = .scaleAspectFit
self.navigationItem.titleView = logo
结果是,它不再考虑帧的高度。
我们可以控制UINavigationbar标题视图的大小和位置。不要使用直接将imageview设置为titleview。在这里创建一个自定义UIView,然后根据需要设置框架,并添加徽标作为其子视图
喜欢
let supportVie = UIView(frame: CGRect(x: 0, y: 0, width: 70, height: 25))
// Here you can set View width and height as per your requirement for displaying supportVie position in navigationbar
//supportVie.backgroundColor = UIColor.red
let logo = UIImageView(image: UIImage.logo ) //UIImage(named: "SelectAnAlbumTitleLettering")
logo.frame = CGRect(x: 45, y: 5, width: supportVie.frame.size.width, height: supportVie.frame.size.height)
// customize the origin as (45,5) but can pass them as your requirement.
supportVie.addSubview(logo)
//supportVie.contentMode = .center;
navigationItem.titleView = supportVie
您想设置高度25
Always就是这样。我希望我的头衔有那么高。