With SwiftUI 2, it’s incredibly easy to add keyboard shortcuts to actions and to add buttons to your app’s menu bar.
You can add keyboard shortcuts to actions simply by adding
.keyboardShortcut(_:) to the button:
You can set nearly every character as
KeyEquivalent . But note, that you can’t toggle the button by simply pressing “B”. When using letters like “V”, you need to press “⌘⇧V”, when using numbers like “6”, you need to press “⌘6”. You can also specify your own modifier keys, by passing them to the
You can define a single one, or…
When you have an iOS app, especially when it displays information, you maybe use
InsetGroupedListStyle on your
List . This looks any like this:
But there is a problem, when you want to display this view on macOS.
InsetGroupedListStyle is unavailable for native apps (It’s available for Mac Catalyst though). And when you use alternative list styles for the list, it looks like this:
Since iOS 13 Apple has a Google Street View like feature to look around cities, called Look Around. With macOS 11 Big Sur, you can now useLook Around on Apple Maps for Macs. In this article, I will compare both services.
Look Around can be used in the Apple Maps app for iOS and macOS. Street View can be used in the Google Maps app, the Google Street View app, the Google Earth app, Google Maps in the browser, etc. You can see, Street View is much more accessible that Look Around, especially when you put other operating systems into…
There are two things to consider when building an app, that should look good on every device. Different screen sizes and text scaling. And that’s what this short article is about, so let’s dive right into it.
When you add a frame to shapes or views, with absolute values, you will probably notice, that it doesn’t look good on every device. And if not, run on multiple simulators. Or even easier, change the device and see the changes in the Live Preview.
With iOS 13 Apple changed from a big, disruptive UI for silent mode and volume to smaller and more focused UIs, that don’t take up the whole screen. There are buttons in your app, where a feedback is more intuitive for the user, but not so important to disrupt the whole screen with an
ActionSheet . Examples are “Added to favorites” or “Saved image”. For that, a simple info sheet at the top is great.
The HUD will be displayed in a layer above the main app interface. To do so, wrap the view elements in your
ContentView in a…
Menu can be both used to display quick actions. Context menus can be used, to add actions to an object, for example an image, and menus are more for view wide actions, like changing list filters. Both look nearly the same, but context menus enlarge the object and blur the background. while menus just cast a shadow. Context menus can be toggled by a long press, menus by a simple tap. In this article, I will explain when to use them, how to use them and what you can do with them.
Context menus add quick actions to…
Group boxes can be used, to group content together. With SwiftUI 2 they are also available on iOS. A default
GroupBox has two possible states. Without a label, the background size depends on the content. With a label, the background pushes to the side.
The syntaxt of a
GroupBox is pretty simple. Instead of the text you can use every view.
By default, the content is put in a
In my opinion, group boxes are great to display information, stats, achievements, history and more. A great example is Apple’s Health app. …
Pickers can be used to let the user select a value from a fixed set of options.
There are multiple types of pickers in SwiftUI,
ColorPicker and in some way also
The most prominent way of creating a picker is with an Integer value. But you can also use every other value type as selection. For example boolean values:
Of course, boolean pickers like that are kind of sensless and should be better replaced with a
Toggle , but if you only have two values, that don’t represent
When you have a media app, you probably want a “Now playing bar”, just like Spotify, Apple Music, YouTube or Podcasts. But you don’t need to be a media app, to have a info bar at the bottom. In this article I will show how to add a “Now playing bar” and some examples, on how to implement an info bar in your SwiftUI app.
When you have a media app, it probably looks anything like this:
With SwiftUI 2 you can open URLs with the new
Link structure. You can also open URLs in-app with a
SFSafariViewController . But maybe you want to give the user the choice, if he wants the link to be opened in-app, in Safari or even in other browsers like Google Chrome, Firefox or Opera.
The selection will be stored in
UserDefaults . If you only want to give the user two options, you can use a
Bool value, if you want multiple use
For every other browser put this in the
Hi. I’m a German student loving everything Apple. I recently started iOS development, focused on SwiftUI