Codable in Swift

In this article I want to provide quick code samples to help you solve answer common questions and solve common problems, all using Codable. Table of contents Nested types Snake...

Attributed String with Style

Have you ever had the feeling that your NSAttributedString were not in the right place in your code? That you were mixing view details and data logic? It happened to...

Managing different Environments using XCode Build Schemes and Configurations

It’s best practice to have separate environments for your iOS apps, especially if they are communicating with any servers. For instance, consider an iOS app and three different available web...

How to make multi-line text in UIButton

The default appearance of UIButton is a single line text, but it also supports a multi-line text with some minor tweak. Programmatically To make a multi-line text in UIButton, you...

Adjust Views To Fit the Keyboard

With a scrollable view — whether that’s a UITableView, UIScrollView, or even a UIView — when the keyboard appears, it takes up space and typically means you have to adjust...

How to Create a Draggable Floating View in Swift

import UIKit class ViewController: UIViewController { @IBOutlet weak var draggableView: UIView! override func viewDidLoad() { super.viewDidLoad() self.draggableView.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handler))) } @objc func handler(gesture: UIPanGestureRecognizer){ let location = gesture.location(in: self.view)...

Useful of Protocol

We might all have gone through the pain of spending a lot of time to implement a function, but then realize that Swift has a built-in function that does the...

Drawing using UIBezierPath and CAShapeLayer

Every view in iOS has a CALayer with it which can be used to add multiple customised layer inside it. It works similar to any UIView, we can have a...

Add shadow and better shadow performance on views

Here’s a simple example to get you started: let yourView = UIView() yourView.layer.shadowColor = UIColor.black.cgColor yourView.layer.shadowOpacity = 1 yourView.layer.shadowOffset = .zero yourView.layer.shadowRadius = 10 There are four you need to...

Working with CALayer in Swift

What is CALayer? CALayer is an object responsible for drawing and animations and it is part of Core Animation framework. Each UIView backed by CALayer class, and you can easily...