防止UINavigationItem的TitleView闪烁

时间:2018-02-12 20:03:35

标签: ios swift uinavigationbar ios11 uinavigationitem

我使用UINavigationItem s titleView属性在我的ViewController的UINavigationBar中心设置视图。问题是,当我推送另一个具有相同titleView的ViewController时,它会闪烁。

Animation showing Blinking of titleView

以下是我在ViewControllers

中设置titleView的方法
let view = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
view.backgroundColor = .red
self.navigationItem.titleView = view

我该怎么做才能防止这种情况发生?

1 个答案:

答案 0 :(得分:0)

我最终使用自定义视图并将其作为subView添加到server { listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default_server ipv6only=on; ## listen for ipv6 root /var/www/html; index index.php index.html index.htm index.nginx-debian.html; server_name localhost; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } } 。我还将UINavigationBar s UINavigationItem设置为空白视图,以防止出现LargeTitle代替我的观点。