Fora Soft
Posted on October 18, 2021
Apple is the leader on the phone market not just because they produce high-quality smartphones, but also because they, unlike other companies, do pay attention to details. Iâll just tell you how to make an Apple-like application. All weâll need to do that is just a couple of lines with a code, nothing too complicated. You donât have to use any external libraries, you can just do with whatever Apple has provided for you.
1. Taptic engine
Taptic engine is a new vibration by Apple, and this solution was initially integrated into iPhone S6. Itâs a small engine that can produce different vibrations. The best thing about it is that Apple has allowed developers to work with it.
Use scenarios:
When you press a button. Your app will be way more appealing if it doesnât only respond to a user doing something by changing the content on the screen, but if it also responds physically.
When you scroll the content. A lot of people own wristwatches. Do you enjoy the sound when you wind yours? So why not add it to your app? This mechanic allows you to help a user dive into content more, it becomes more interesting for him to scroll down the feed. Thus, we make the user stay in our app for a longer period of time.
When an error appears. You always have to put some effort into making sure your program doesnât have errors. However, there are situations where the user is the one responsible. For instance, if they entered the wrong password. Of course, weâll show a pop-up notifying them of that, but we can also do that using our engine.
Taptic engine helps add the Apple magic we all know and love.
Realization:
let mediumGenerator = UIImpactFeedbackGenerator(style: .medium)
mediumGenerator.impactOccurred()
2. Spotlight indexing
Whatâs your iOS device memory capacity? 128 GB, 256 GB, more? How many apps are on your smartphone? 50.100? Can you imagine the amount of data stored on your phone? In order for a user to not get lost in that large information stream, Apple has added Spotlight.
Spotlight is a mechanism that allows you to find data on the device thatâs operated by macOS, iOS, or iPadOS. Unfortunately, Spotlight only helps to locate the app, but iOS 9 introduced the functionality of indexing the data within those apps.
Unfortunately, not all apps are indexed so letâs be the first ones in order to be ahead of the competition!
Is your app a mail aggregator? Letâs search in letters! There are dozens of different ways to use Spotlight. What we have to do is accentuate the main task of the app.
Realization:
import CoreSpotlight
import MobileCoreServices
Add an index now.
func indexItem(title: String, desc: String, identifier: String) {
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeText as String)
attributeSet.title = title
attributeSet.contentDescription = desc
let item = CSSearchableItem(uniqueIdentifier: "\(identifier)", domainIdentifier: "com.uniqeCode", attributeSet: attributeSet)
CSSearchableIndex.default().indexSearchableItems([item]) { error in
if let error = error {
print("Indexing error: \(error.localizedDescription)")
} else {
print("Search item successfully indexed!")
}
}
}
Now, processing the app opening with a unique index.
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType == CSSearchableItemActionType {
if let uniqueIdentifier = userActivity.userInfo?[CSSearchableItemActivityIdentifier] as? String {
//doSomethingCoolWith(uniqueIdentifier)
}
}
return true
}
3. Animation upon pressing
The animation that Apple provides is very simple.
I suggest that we improve it a bit. Why? Itâs a lot more comfortable for a user when they change an itemâs form by slightly touching it. It creates somewhat of a connection between an application and a user.
Realization:
extension UIView {
func addAnimate() {
let xScale : CGFloat = 1.025
let yScale : CGFloat = 1.05
UIView.animate(withDuration: 0.1, animations: {
let transformation = CGAffineTransform(scaleX: xScale, y: yScale)
self.transform = transformation
}) { (_) in
let transformation = CGAffineTransform(scaleX: 1, y: 1)
self.transform = transformation
}
}
}
Do not forget about point one from this article! A combo of animation and taptic engine is simply amazing.
4. Permission requests
No one likes to share their geolocation but we still have to, otherwise, the maps wonât work.
Now, imagine: your app works with a camera, microphone, geolocation, contacts. So when do we ask permission from a user?
Bad decision:
Ask permission for everything at the first launch
- Quite fast
- The negative attitude from a user to such an app as they donât understand why they need all this.
- The developer still has to check permissions before the actual module use.
Optimal decision:
Request permission before the actual use
- Userâs trust isnât undermined;
- The developer doesnât do double work.
Advanced decision:
Onboarding that definitively describes where and what for will the phone be used.
- User understands exactly why he has requested permission;
- The program becomes more user friendly;
- Developing takes a lot of time;
- Developer does double work as they have to check permission before the actual module use anyway.
I think that the Optimal decision strategy is the best here.
5. Home Screen Quick Actions
There is a 3D Touch function in iPhone (Haptic Engine in the modern iterations). Roughly speaking, this technology allows to understand the power with which you press the screen. This can be integrated into an app. For example, upon pushing the element hard, an event occurs. This, however, didnât get wide recognition. I believe itâs because the user has to understand on their own whether a button has hidden functionality. Therefore, this function isnât on the top of the priority list.
However, itâs different when the Home screen is involved. All icons have the âhard pushâ function. If the developer hasnât done anything, the Home screen will provide the following functions:
- Change the Home screen;
- Share application;
- Delete application.
Starting with iOS 12, this functionality can be widened by adding actions that you want. As a rule of thumb, the main featuresâ functionality is integrated there. For example, this is what Instagram offered:
- New post;
- Check actions;
- Direct. Pressing any of those will take you to the corresponding event.
You may find Apple documentation down below. Although it might seem that thereâs lots of code, realization wonât take too much time.
6. Dark Mode
iOS fans were waiting for a new dark theme for years. Developers didnât,
Starting with iOS 13, the phone has two modes: light and dark. Change it in the settings, and all applications will change their interface. Roughly speaking, if a button is blue when the flight mode is active, it will go red once you switch to the dark mode.
I switch modes quite a lot on my iPhone. When I see that the app changed color on its own, Iâm happy. You can see that developers tried harder and introduced a function. Itâs a small but nice addition.
Letâs see how this works taking our Russian Instagram as an example:
In my new project, I have decided to work with colors differently. Before, people used to create a separate file with app colors. I, however, have created a Color Set. Only the dark theme is supported by the app now, but if thereâs an urgency to add a light theme, itâll take no more than 30 min. You just have to know what color is used when swapping to the light theme.
Now the color is always red regardless of the theme. But if thereâs yellow instead of red in the light theme, I will just need to change the color here. You donât have to do anything inside the code.
This solution has increased the developing time by 30 min. But if we decide to go with the dark theme, weâll save about 20 hours!
7. iOS Modal Sheets
There are two ways of accessing a new window in iOS â when it appears on the right and at the bottom.
First option:
Second option:
Weâll be talking about option 2. Prior to iOS 13, it was working by opening a new window immediately on top of the previous one. Starting from iOS 13, it works differently by default.
We see on the gif that a window opens on top of the previous one but it doesnât cover the entire screen. This is called Modal Sheets. Developers went on to fix in in Summerâ19, by adding an attribute vc.modalPresentationStyle = .fullScreen. This trick allowed them to get back to the way apps opened as it showed on gif 2.
Now a new window would open full screen. It was a quick fix in order to avoid bugs. Why so? Because fullScreen has to add a close window button on its own and pushing it is easy to process. If you use Modal Sheets, you can just drag the window down, and iOS will close the window and remove it from the device memory. It can cause bugs, however â uncontrollable behavior, for instance.
This way of closing windows can be controlled via delegate:
extension BaseViewController: UIAdaptivePresentationControllerDelegate {
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
viewControllerWasDismissed?()
}
}
Logic has to be inserted here. For example, the same as the âcloseâ button has.
Letâs use Modal Sheets, avoid fullScreen if you can. Modal Sheets makes an app fresher, modern and the UX is similar to Apple applications.
8. System font size
Did you know that you can change the font size in iOS? This function is awesome for you if you have trouble seeing small objects. The size will change in all system applications.
Thatâs not all! You can set your font size so that it depends on the one in the system. This improves your interaction with apps, especially if thereâs a lot of text in there.
Youâd ask whether itâs easier to get a bigger size from the start? No, itâs not. I, for example, donât like huge letters. Letâs think about all users, thus getting even more of them!
This is the technology description from the official documentation.
9. Password AutoFill and Strong Password
Why will I never move to Android? There are more than 300 accounts in my password list, and I think you too have quite a few of them. Thatâs it, no more questions. Itâs convenient.
Whoever doesnât know what Iâm talking about, Iâll explain. Your login and password are stored in a secure place. Why is it secure? Apple will answer.
You donât need to write down your password on a piece of paper anymore (may my grandfather forgive me for this), nor you need to come up with passwords by yourself. Do you use the same password everywhere? Congratulations, you are at risk. This mechanism generates a strong password for you and automatically adds it to Keychain. The program will suggest a suitable password for authorization upon your next login.
In order for this to work, you need to add Associated Domains on the server and list it in Capabilities in the app.
Donât forget to mention type at the filling field in an iOS app.
Conclusion
Weâve explained how we can make an application way more appealing using small features. Donât forget about small things, so your application can be âhugeâ!
Posted on October 18, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.