我的导航栏中有一个标题,ai想要将其更改为自定义字体.我找到了这行代码,但它适用于你有导航控制器的时候.
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!,
NSForegroundColorAttributeName: UIColor.whiteColor()]
Run Code Online (Sandbox Code Playgroud)
但我没有任何导航控制器.我手动添加导航栏到我的视图.
我该如何更改评论字体?
我正试图解雇一个VC并提出一个新的VC.但我不希望旧的VC再存在.我使用下面的代码来关闭当前的VC并提供新的VC.但是这样,在解雇和现在之间有一段时间间隔.我不希望用户注意到这一点.所以,我想首先提出新的VC然后解雇前一个.有没有办法做到这一点?
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationController = self.storyboard?.instantiateViewController(withIdentifier: "login") as! Login
let presentingVC = self.presentingViewController
self.dismiss(animated: false, completion: { () -> Void in
presentingVC!.present(destinationController, animated: true, completion: nil)
})
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 alamofire 发布 http 请求。我的要求如下:
let url = "\(myBaseURL)/{name:adriana lima}"
Alamofire.request(url.addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!, method: .post)
Run Code Online (Sandbox Code Playgroud)
我尝试了一些编码类型,例如:
urlFragmentAllowed ,空格
但他们不工作。
我知道如果我使用参数,空格会被处理,但在这种情况下,我必须在 url 内传递参数。但它导致错误。我如何发布这个以及我应该如何编码它?
我有一个tableview,并且我想在点击行之一时转到另一个vc。我的didSelectRowAtIndexPath函数如下。print命令有效,并显示右键单击的行。但是当我使用self.navigationController?.pushViewController时,它不会通过playVideo storyBoardId进入vc。将其更改为presentViewController后,它可以工作。我的代码有什么问题,推送不起作用?
谢谢
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("clicked " + String(indexPath.row) )
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("playVideo") as! PlayVideoViewController
vc.id = self.video[indexPath.row].id
// Present View as Modal
//presentViewController(vc as UIViewController, animated: true, completion: nil)
// Push View
//self.navigationController?.pushViewController(vc, animated: true)
}
Run Code Online (Sandbox Code Playgroud) 我的整个应用程序(所有视图控制器)都有背景,我想根据一天中的时间更改它。如果时间是上午 6:00,我想显示“背景一”,如果时间超过晚上 9:00,则应显示“背景二”。我正在考虑使用 NSTimer 来检查当前时间是否超过定义的时间。为了改变背景,我正在考虑使用 UIViewController 的扩展。如果有更好的解决方案,欢迎分享。