Nitin Aggarwal has Published 156 Articles

Finding the index of a character in a Swift string

Nitin Aggarwal

Nitin Aggarwal

Updated on 04-Apr-2023 10:32:00

2K+ Views

In iOS app development, it is common to find the index of a character in a string. Based on the given index, you can perform different actions. In this article, you will see some examples of how to get the index of a character using the below functions − ... Read More

How to return the first 5 objects of an array in Swift?

Nitin Aggarwal

Nitin Aggarwal

Updated on 04-Apr-2023 10:23:43

2K+ Views

In Swift to get the first N objects of an array, we can use the prefix function or Range operator. This prefix function is used to retrieve the prefix elements by passing the count limit. Also, you can use the range operator to get n number of elements from an ... Read More

How to dismiss ViewController in Swift?

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:48:51

3K+ Views

In Swift, we have a dismiss method of the class UIViewController that can be used to dismiss a ViewController in Swift. In this method, a Boolean value is used as an argument. There is an argument in this argument that asks whether the dismissed controller should be animated. By default, ... Read More

How to Apply Gradient to the background view of the iOS Swift App?

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:46:00

6K+ Views

In iOS, there is a class CAGradientLayer to apply gradient colors to views. In this article, we will look at how you can use the CAGradientLayer class to apply gradients to the background of a view in iOS. The CAGradientLayer class provides different properties like colors, locations, points, frame, etc. ... Read More

Get input value from TextField in iOS alert in Swift

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:37:45

1K+ Views

Generally, we use UIAlertController to show an alert with a dismiss action button. But UIAlertController provides you with more flexibility to add UITextFields to the alert. Let's see some examples of different use cases. When you add a text field to the UIAlertController, you can take the input value entered ... Read More

Move the text field when the keyboard appears in Swift

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:34:04

2K+ Views

In real iOS applications, most of the time you deal with UITextFields for taking various inputs. In order to make the text fields visible while editing, you can manage the constraints by updating them. To manage the constraints, you have to add observers for keyboard showing and hiding. In this ... Read More

How to stop unwanted UIButton animation on title change?

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:29:57

466 Views

In iOS applications, you will often need to customize the button according to your requirements. When you add a button to the parent view, the button title is animated by default. But if you want to stop that default animation, you can use the custom button in UIKit. We will ... Read More

How to set back button text in Swift?

Nitin Aggarwal

Nitin Aggarwal

Updated on 27-Mar-2023 15:27:46

1K+ Views

By default, a view controller shows the text "Back" with an arrow on the back button in iOS. But you can set a custom title and icon for the back button item. Let's see an example of how to set custom back button text in Swift. In this example, we ... Read More

What is the difference between a weak reference and an unowned reference?

Nitin Aggarwal

Nitin Aggarwal

Updated on 24-Mar-2023 10:03:57

4K+ Views

Understanding iOS memory management is essential for iOS and macOS development. The concept of weak self and unowned self is challenging to understand, especially for beginners. ARC (Automatic Reference Counting) may have solved many problems for us. Swift still requires that you manage references a lot of the time when ... Read More

What is the 'some' keyword in SwiftUI?

Nitin Aggarwal

Nitin Aggarwal

Updated on 28-Feb-2023 13:27:08

1K+ Views

The "some" keyword in SwiftUI is used to indicate that a type conforms with a protocol, but the exact conformance is not specified. The AnyView type, a type-erased view that can represent any view conforming to the View protocol, is commonly used in association with it. SwiftUI defines some View ... Read More

Previous 1 ... 6 7 8 9 10 ... 16 Next
Advertisements