😎 9 little things to make your iOS application look cooler
Tags: ios, beginners, tutorial, swift
Published: 2021-10-18 19:31:52

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyx0hh6hmqdgkir79dpl.png)
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()
```
## 2. Spotlight indexing

![spotlight-indexing-ios](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k3m2srfndbqyae5yeme1.png)
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.

![ios-basic-animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tinqqm7x2x5lk1is59wq.gif)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytfzn2o9idwv6iaj66r1.gif)

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

![ios-permission-requests](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f01od0p5kmqjyr5kqp2y.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvckojg4vizgcjfd5i80.png)
* 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/99sks9d1mxng8o9dow1w.png)
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](https://developer.apple.com/documentation/uikit/menus_and_shortcuts/add_home_screen_quick_actions)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8yg0g1q5mh7rtsrox0yh.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc6jkud9ymlwdxbfgk9y.png)
Let’s see how this works taking our Russian Instagram as an example:
![fora-soft-instagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/85nmrbh4p16qnnmbe0d4.gif)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55pndvlggkoqttn33z2n.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vipmt19uiqvjtkad8afm.gif)
Second option:
![iOS-Modal-Sheets-bottom](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wvl1taqsznljo28zwvvm.gif)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zcmilj9nvmlxtvo0pn32.gif)
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.
![iOS-Modal-Sheets-example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xtguoe2cfwfvr8bmtu5k.png)

## 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](https://developer.apple.com/documentation/uikit/uifont/scaling_fonts_automatically).

## 9. Password AutoFill and Strong Password

![iOS-Strong-Password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ucdivhcgcf4zxlxei98f.png)
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](https://developer.apple.com/documentation/security/keychain_services).

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”!