- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我知道可以使用 prefersLargeTitles
为 «large» 和 «small» 标题分别设置字体系列、字体大小和颜色。
问题是:导航 Controller 是否有任何选项可以在打开的导航面板中以大写字母显示 «large title»?
现在我使用自定义导航 Controller :
class MyNavigationController: UINavigationController {
public var titleSaved: String?
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
guard let topItem = navigationBar.topItem else {
return
}
if navigationBar.frame.size.height > 60 {
topItem.title = topItem.title?.uppercased()
} else {
if let titleSaved = titleSaved {
topItem.title = titleSaved
} else {
topItem.title = topItem.title?.applyingTransform(StringTransform(rawValue: "Title"), reverse: false)
}
}
}
}
从 View Controlle 设置标题:
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.prefersLargeTitles = true
let title = "Sign In"
navigationItem.title = title
if let nc = navigationController as? MyNavigationController {
nc.titleSaved = title
}
}
}
这个解决方案有效,但是当你从“大”标题切换到“小”标题并向后切换时,它会抽动并且看起来很糟糕
最佳答案
您可以使用 Small caps fonts 为 «large title» 设置大写标题,为 «small title» 设置大写标题
将titleTextAttributes
改成其他字体,将largeTitleTextAttributes
改成caps字体
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Sign In"
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
self.navigationController?.navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.red,
.font:UIFont(name: "Panton-LightCaps", size: 30)!]
}
}
或者您可以自定义您的字体。我在 http://www.glyphrstudio.com/online/ 中使用 OpenSans 创建了一种新样式字体
可以下载here
self.title = "Sign In"
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.titleTextAttributes = [.font:UIFont(name: "OpenSans-Regular", size: 30)!]
self.navigationController?.navigationBar.largeTitleTextAttributes = [.font:UIFont(name: "MyFontRegular", size: 30)!]
关于swift - 如何使用 prefersLargeTitles 更改所有权注册表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55370707/
我正在使用 tcod-rs。用于绘制到 RootConsole 的每个方法都采用一个可变引用。中央循环是一个 while 循环,它等待窗口关闭、清除屏幕、绘制,然后刷新。 “检查窗口关闭”方法也采用可
我写了一个具有这种形式的函数: 结果 f(const IParameter& p); 我的意图是这个签名将明确表明函数没有取得参数 p 的所有权。 问题是 Result 将保留对 IParameter
这个问题在这里已经有了答案: 关闭 9 年前。 Possible Duplicate: What is a smart pointer and when should I use one? 我正在阅
假设我有一个类: class Scheduler { Scheduler(JobService *service); AddJob(JobID id, ISchedule *sched
我试图弄清楚所有权如何与函数 CVMetalTextureGetTexture 一起工作: CVMetalTextureRef textureRef; // ... textureRef is cre
这个问题在这里已经有了答案: Should we pass a shared_ptr by reference or by value? (10 个答案) 关闭 4 年前。 例如 class A {
我正在做一个附带项目,我需要根据他的 gmail 帐户或任何其他参数来验证 channel 是否属于某个用户……这基本上是为了避免假帐户。是否可以? 最佳答案 是的, 跟随 youtube 记录的链接
我在使用Core Foundation Array时发现了一个奇怪的问题!这是代码片段 fname = CFStringCreateWithFormat(kCFAllocatorDefault, NU
有没有一种方法可以设置在 apache 下运行的 php 来创建文件夹,该文件夹的文件夹属于创建它的程序的所有者,而不是由 apache 拥有? 使用 word press 它会创建要上传到的新文件夹
我编写了以下函数来使用 boost.date_time 获取日期/时间字符串. namespace bpt = boost::posix_time; string get_date_time_stri
我在使用 Docker 容器时遇到了一个有点烦人的问题(我在 Ubuntu 上,所以没有像 VMWare 或 b2d 这样的虚拟化)。我已经构建了我的镜像,并且有一个正在运行的容器,它有一个来 sel
根据大多数示例,逻辑上最少有 3 个组织 ( org1, org2, orderer )。 实际上只有 2 个物理组织 ( org1, org2 )。任一组织或约定的第 3 方必须移交订购者组织的职责
我开始学习 Rust,在进行实验时,我发现所有权如何应用于我不理解的元组和数组的方式有所不同。基本上,以下代码显示了差异: #![allow(unused_variables)] struct Inn
我们有一个应用程序,其表单上有许多组件(面板、选项卡、编辑、组合框等)。但根据用户配置文件,其中大多数可以自动填充和/或不可见。因此,用户可以更快地完成工作。 问题:是否有更简单的方法可以在运行时创建
我有以下代码片段: fn f u32>(c: T) { println!("Hello {}", c()); } fn main() { let mut x = 32; let
我想执行示例中的代码: require_once 'google-api-php-client/vendor/autoload.php'; $client = new Google_C
这个问题在这里已经有了答案: What is move semantics? (11 个答案) 关闭 3 年前。 我有一个看起来像这样的构造函数: Thing::Thing(std::vector
我们正在使用服务帐户从服务器上传文件,但它已达到其存储配额限制。所有文件都已添加到另一个用户(具有 100 Gb 存储配额的 @gmail.com 帐户)创建的文件夹下,但上传的所有文件均归该服务帐户
我正处于 this question 中描述的 sme 情况。 .那个提问者找到的解决方案是 Full access !== Owner. I need to read the documentati
我正处于 this question 中描述的 sme 情况。 .那个提问者找到的解决方案是 Full access !== Owner. I need to read the documentati
我是一名优秀的程序员,十分优秀!