I'm working on a project in swift for iPad
.
Have placed an image view in Navigation bar title view from story board.
The title view is displaying as expected in iOS 10
and below.
The same project when i run in iOS 11 simulators and the physical devices Navigation bar is not showing the title view, any leads would be appreciated.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Create a custom view and override below method in the custom title view class to update view frame size at runtime.
Obj-C
-(CGSize)intrinsicContentSize
{
[super intrinsicContentSize];
return UILayoutFittingExpandedSize;
}
Swift
override var intrinsicContentSize: CGSize {
return UILayoutFittingExpandedSize
}
Check and let me know is it working for you or not ?
回答2:
Maybe this can help you
let widthConstraint = view.widthAnchor.constraint(equalToConstant: width)
let heightConstraint = view.heightAnchor.constraint(equalToConstant:height)
widthConstraint.isActive = true
heightConstraint.isActive = true
view
is the view that you use as a custom title view. And width
and height
is the size that you want to use. You can use:
let width = view.frame.width
let height = view.frame.height