自定义标题视图未在iOS 10中居中 [英] Custom Title View not Centered in iOS 10

查看:45
本文介绍了自定义标题视图未在iOS 10中居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇文章是一个单独的主题,但与

来自项目: https://github.com/ekscrypto/Swift-教程自定义标题视图

要重现此问题,只需在现有的Root View Controller上放置一个按钮,即可按下另一个View Controller.<返回"按钮将标题拖到上方,这使标题严重居中.我怎样才能解决这个问题?谢谢.

解决方案

支持iOS早期版本所需的简单更改;您应该适当地调整自定义标题视图的大小,使其为其实际的预期宽度.iOS 11会根据限制尝试调整标题视图的宽度以适合可用空间,但iOS 10及更低版本将尝试保持尽可能大的视图大小.

因此,解决方案是打开MyCustomTitleView.xib文件,并将MyCustomTitleView的宽度设置为合理的值,例如180pt.

干杯!

This post is a separate topic but related to Custom Nav Title offset ios 11

I created a new thread because it is a separate issue.

From project: https://github.com/ekscrypto/Swift-Tutorial-Custom-Title-View

To recreate the problem, simply put a button on the existing Root View Controller that pushes another view controller. The "< Back" button scoots the title over, which makes it terribly uncentered. How can I fix this? Thank you.

解决方案

Simple change required to support earlier versions of iOS; you should properly resize your custom title view to be the expected width its actually going to be. iOS 11 attempts to resize the width of the title view to fit the available space based on the constraints but iOS 10 and below will try to maintain the size of the view as much as possible.

The solution is therefore to open the MyCustomTitleView.xib file, and to set the width of the MyCustomTitleView to something reasonable like 180pt.

Cheers!

这篇关于自定义标题视图未在iOS 10中居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆