0

Good day StackOverflow Community! I have come with the following question: How can I add this sub view, that displays the date of posts someone is currently viewing, into my basic navigation controller? The view is a UITableView. See picture link below what I mean. What I mean can be seen in the red box. You see "Vandaag" this means Today in Dutch. And that is basically what I want, to add a subview into my navigation controller that displays the date of the posts. The coding language I use is Swift.

https://ibb.co/gsLJsv

Now I have to tell you, when it comes to XCode I am greener then a nauseous Hulk. So if it is not clear what I mean, then feel free to point out.

Fangming
  • 24,551
  • 6
  • 100
  • 90
vandernat.p
  • 153
  • 1
  • 1
  • 10

1 Answers1

0

You can use this code:

self.navigationItem.title = @"TODAY";

Or if you want yo have more customizable way, you could use this:

let labelTitle = UILabel(frame:CGRect.zero)
labelTitle.text = "Today"
labelTitle.text.textAlignment = NSTextAlignment.center
navigationItem.titleView = labelTitle
Nikita Gaidukov
  • 771
  • 4
  • 14
  • Thank you for your reply, very useful. Do you know also how I can let it change to the date posts were uploaded? So for example: When it is now "Today" and I scroll further down to lets say 06-21-17 that it displays 06-21-17. – vandernat.p Jul 17 '17 at 06:50
  • @vandernat.p It depends on how your scrollview is set up. But if you asking how to format a date, you should use a DateFormatter object - https://stackoverflow.com/questions/35700281/date-format-in-swift. Please accept the answer if it was helpful. – Nikita Gaidukov Jul 17 '17 at 09:58