I'm Neil, and I’m a software developer in the UK. I mostly work with iOS, and occasionally write about it too, along with various other things.
Check out my blog posts here, or read more about my current setup. And here’s my now page, with everything I’m up to these days. You can find me in more places around the web on my links page.
If you like my writing, please consider buying me a coffee to show your support. Thanks!
In Running Track, I have a screen that shows details about a run, including a map of the route. I’ve been rewriting parts of the app in SwiftUI recently, and that screen has given me a headache!
To have a consistent look across the app, I set UINavigationBarAppearance
on launch. This gives me a standard background colour, tint colour and title font.
static func setNavigationBarAppearance() {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor(.primaryColor)
appearance.tintColor = UIColor(.darkBackgroundText)
appearance.titleTextAttributes = [
.foregroundColor: UIColor(.darkBackgroundText),
.font: RTTextStyle.display4.font
]
appearance.largeTitleTextAttributes = [
.foregroundColor: UIColor(.darkBackgroundText),
.font: RTTextStyle.display2.font
]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
There’s no equivalent of this in SwiftUI. No way to set navigation bar style globally. (I don’t know why not.)
For some reason, if you have a SwiftUI Map
in your UI, it will override any global UINavigationBarAppearance
you set. When the Map
is in my View
, it sets the navigation bar to the default style, a white background in light mode and a dark one in dark mode. (This applies whether you use NavigationStack
or NavigationView
.)
That means you can’t use UINavigationBarAppearance
to style the navigation bar on that screen.
There are two fixes for this, and both involve giving up on UINavigationBarAppearance
and moving to the SwiftUI method of styling individual views explicitly: 1. Style this navigation bar explicitly, and leave the rest to UINavigationBarAppearance
. 2. Get rid of UINavigationBarAppearance
and explicitly style every view that lives in a NavigationStack
.
You can style a navigation bar in SwiftUI with modifiers, but you have to apply them to each view individually:
someView
.toolbarBackground(Color(.primary), for: .navigationBar)
.toolbarBackground(.visible, for: .navigationBar) // otherwise it's hidden until you scroll
.toolbarColorScheme(.dark, for: .navigationBar) // a hack to get white text and button tints
I’m not able to go with the first solution, modifying only the View
containing the map, because SwiftUI doesn’t give the same control over navigation bar styling that UIKit does.
For example, I change the text colour and font in my UINavigationBarAppearance
setup. But can’t change these in SwiftUI’s navigation bar. So I can’t have an exception just for the screen containing the map, without it looking different to the rest of the app. I need to completely change my navigation bar style.
So I’ve had to go nuclear and get rid of UINavigationBarAppearance
.
I created a modifier to reduce some of the repetition, but I have to set it on every View
that's presented in a NavigationStack
:
struct NavigationBarStyle: ViewModifier {
func body(content: Content) -> some View {
content
.toolbarBackground(Color(.primary), for: .navigationBar)
// otherwise it's hidden until you scroll
.toolbarBackground(.visible, for: .navigationBar)
// a hack to get white text and button tints
.toolbarColorScheme(.dark, for: .navigationBar)
}
}
extension View {
func navigationBarStyle() -> some View {
self.modifier(NavigationBarStyle())
}
}
If anyone has a better solution to this, let me know!
(Note: This issue is specific to rendering a Map
, so if you're not using a Map
in your UI you may not need to worry about this.)
If you liked this article, please consider buying me a coffee to support my writing.
I started writing a novel in 2021, and spent a long time writing background, allowing me to shape the world, and also just to get some practice writing. This has been on pause for the last few months, but I’ve picked it up again recently, and decided I wanted to share some of the “other” writing.
The Confession is the first piece of fiction I’ve ever shared, outwith creative writing projects in high school.
It’s about some people who live in the world I'm building, before the main events of the novel. The narrator is (probably) the main character of the novel. He and Thomas are part of the community that is the setting of the novel. The Watchtower is a focal point of that community, but in this story it mostly just adds a little atmosphere. The Troubles aren’t really relevant to the bigger story; they were a vehicle for sharing ideas, and a bit of shock.
I really enjoyed writing The Confession, and hope to share more like this in future. I hope you like reading it.
If you liked this article, please consider buying me a coffee to support my writing.
Thomas approached me one evening, as I was reading in one of the quieter spots near the Watchtower. He had a hesitant look on his face that I'd never seen before. He was an army veteran, and nothing seemed to phase him. He took every setback, every shock, in his stride, even when the rest of us were utterly shaken. But this evening was different.
"What's up, Thomas?" I asked. "You look like a ghost just jumped out from behind a bush wearing your grandma's favourite cardigan!"
He was oblivious to my good humour. "See, thing is..." he started, swallowing his sentence. "I need to..."
"What's wrong, Thomas?" I asked, suddenly concerned. This was not a man who struggles for words, or for anything really.
"I need to confess something," he finally managed to say.
"I'm not a priest Thomas," I said, with a smile on my face. "Come on, spit it out. What's on your mind?"
"I was in the army, back in the '70s," he told me.
"I know. We've all heard the stories," I said.
"Smartarse." That was more like Thomas. "Not this one, you haven't.
"In the '70s, Northern Ireland was a dark place to be. The Troubles were as close to a civil war as you can get without actually being in a civil war. The British Army was fighting against, well, terrorists, really. But they had the support of half of the country, so we were often the enemy, even when we were defending our own country from paramilitaries."
"I've heard about it, but I was born 20 years after all that," I said. "I had no idea. I've heard that it was a tough time, but I’ve always seen it as something that's history now."
"We don't teach people enough real history in this country. Not what matters to the people who still live here. It's all 'how many wives did this old king have', not 'why do these people still hate these people after decades.' It was horrific. And I only know my part of it. There are thousands of other stories all as rough as mine."
He paused here. I could tell he'd gone off on a tangent, he'd been more of his old self for a moment. His face dropped again.
"But my story is why I wanted to talk to you tonight.
"I was 22. I'd been there for a couple of weeks, that's all. It was my first time there, although I'd have a few more visits afterwards. None harder than that one though.
"I was with the British Army. We were fighting against the IRA in Belfast. And we'd caught a good few of them in a raid one morning. Brought them back to our base.
"Some of them were proper bruisers. Built like tanks, sweary fuckers like me, could throw a proper punch and could take as good as they could give. We were lucky we were armed and outnumbered them.
"But some others were just kids. Maybe 16 years old and dragged into their parents' and grandparents' fight. They should have been in school. They should have been sneaking out at night, drinking, getting off with girls, learning what not to do.
"But instead they died in a shitty little garage in some manky corner of Belfast."
Silence followed, for a few moments. There was the generic background noise of the river, and the hum of the living quarters, and that was all.
Eventually, I had to ask: "what happened to them?" This seemed to be what Thomas had been both waiting for, and dreading.
"The fuck do you think happened to them? They all just had spontaneous heart attacks? We killed them. We slaughtered them. Every last one of them lost their lives. Ten men and boys, killed because of their politics. Killed because we were scared of what they might possibly do if we didn't kill them. Killed because it was easier than keeping them prisoner. Killed for revenge for our lost brothers. But worst of all, killed because they were unarmed and it was easy."
He paused. He'd let some of the emotion out that he'd clearly been holding in while we spoke earlier, and he seemed to be catching his breath again.
"Most of us didn't want to do it. But that's how the army works, you do what you're told. The Troubles were hard, and they made monsters out of some people who'd been there too long. My Sergeant was one of them. He'd lost too many good men, he told us. We had a great opportunity to finally clean up a part of Belfast, and we shouldn't let it go to waste. I don't remember him ever telling us that he'd had authority from anyone above him to kill unarmed, untried prisoners, and they certainly acted shocked enough when they found out. But nothing ever came of it, ultimately.
"I don't know why I'm telling you this. I'm getting old, and I can't live with it on my conscience, I suppose. Especially in times like these. We've all done bad things, but it feels like there's a reset coming and I want to be cleaner when it comes.
"But I suppose there's also a lesson I want to share. The world is changing. There's a lot of one-dimensional thinking. Peace is disappearing, there's a lot of fear. I see a lot of what I saw in Belfast in the '70s. Everyone was scared then, not knowing where the next attack could come from, never feeling safe. To my Sergeant, the IRA were the enemy, and it was as simple as that. So many people thought like that, on both sides. Without thinking of people as complex humans first and foremost, we reduce them to just one aspect of themselves. We dehumanise them, turning them into a thing instead of a person; something to fear, something to hate. Always remember that people are people. Don't make my mistake. It's haunted me ever since."
The hesitant look was back on Thomas's face. "There's something else too. I need to tell you about ‒"
There was a loud bang, and Thomas hit the ground, the shadow of the Watchtower not entirely hiding his shocked and bloody face.
If you liked this story, please consider buying me a coffee to support my writing.
I like to check in on my home screen periodically and see how things evolve. This is my third post containing a home screen, you can see past versions under the homescreen tag.
This is my daytime home screen. There are a few changes from last time.
Mostly my Dock is the same:
But I've got a new browser. I replaced Safari with Vivaldi. There are a few reasons, which I won't go too deeply into (I have another post in the works for that rabbit hole), but to sum it up, I'm trying to avoid giving money or data to big US companies, where I can. And Vivaldi is pretty good, so I've switched over to using it as my browser on all devices.
In removing the Carrot widget, I've got a lot more space for apps, so I added another row, then kept one more row free, to avoid visual overload. Notable changes that I've made in the app icons I keep around:
The extra row of apps on my home screen is dedicated to fitness.
My aim with my evening home screen is to try to make my phone calming, and less distracting. I want to use it less in the evenings, and do things like read or watch TV to wind down. When I do use my phone, I want to make it look less bright and vibrant. I love the new dark app icons and tinted icons for this.
I try to keep my watch faces as useful as possible. I don't use it for a huge amount of stuff, so anything I do use it for should be accessible from the watch face rather than tapping into the app grid, where possible.
I have the same approach to night mode on my watch as on my phone.
If you liked this article, please consider buying me a coffee to support my writing.