DEV Community

Cover image for šŸ˜Ž 9 little things to make your iOS application look cooler
Fora Soft
Fora Soft

Posted on • Updated on • Originally published at forasoft.com

šŸ˜Ž 9 little things to make your iOS application look cooler

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-ios
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:

  1. 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.

  2. 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.

  3. 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()
Enter fullscreen mode Exit fullscreen mode

2. Spotlight indexing

spotlight-indexing-ios
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
Enter fullscreen mode Exit fullscreen mode

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!")
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

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
}
Enter fullscreen mode Exit fullscreen mode

3. Animation upon pressing

The animation that Apple provides is very simple.

ios-basic-animation

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.

improve-ios-animation

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
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Do not forget about point one from this article! A combo of animation and taptic engine is simply amazing.

4. Permission requests

ios-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.
app-permission-requests

  • 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

ios-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.

Apple documentation

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.
ios-black-theme

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.
ios-dark-mode
Letā€™s see how this works taking our Russian Instagram as an example:
fora-soft-instagram
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.
color-set-ios-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:
iOS-Modal-Sheets
Second option:
iOS-Modal-Sheets-bottom
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.
iOS13-Modal-Sheets-bottom
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?()
    }
}
Enter fullscreen mode Exit fullscreen mode

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.
iOS-Modal-Sheets-example

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

iOS-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ā€!

Top comments (0)