简体   繁体   English

如何添加到UINavigationBar标题背景和填充

[英]How to add to UINavigationBar title background and padding

I'm trying to implement this design into app. 我正在尝试将此设计实现到应用程序中。

机针视图
My first plan was to add solid background and some padding to title view, but I couldn't find any info. 我的第一个计划是在标题视图中添加纯色背景和一些填充,但是我找不到任何信息。 As I understood I can set only title view text attributes via setTitleTextAttributes on [UINavigationBar appearance] 据我了解,我只能通过[UINavigationBar外观]上的setTitleTextAttributes设置标题视图文本属性

Now my Navigation Bar looks like this 现在我的导航栏看起来像这样

What is the better way to implement this design into app? 将这种设计实施到应用程序中的更好方法是什么?

Do the following: 请执行下列操作:

1.set the checkers pattern as the background image. 1.将方格图案设置为背景图像。 2.create a UILabel with desired with and height, set text or attributed text. 2.使用所需的和高度创建一个UILabel,设置文本或属性文本。 3. self.navigationItem.titleView = yourLabel 3. self.navigationItem.titleView = yourLabel

This is more robust than simply making the whole thing a background image because it allows you to change the title for different screens while having the same checkered background. 这比简单地将整个背景制作成背景图像更为强大,因为它允许您在具有相同方格背景的同时更改不同屏幕的标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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