Found 33676 Articles for Programming

Converting URL to String and Back Again in Swift

Nitin Aggarwal
Updated on 04-May-2023 11:33:38

3K+ Views

In Swift, you can convert a URL to a String using the absoluteString property of the URL. To convert a string to a URL, you can use the URL(string:) initializer. In this article, you will see many different examples of how to convert an URL to a string and vice versa. Example 1: Converting URLs to Strings and Vice Versa for converting a URL to a string using the absoluteString property and a string to a URL, you can use the URL(string:) initializer. It also mentions that the URL(string:) initializer returns an optional URL value that should be checked for ... Read More

Obscure a UITextField Password in iOS

Nitin Aggarwal
Updated on 04-May-2023 10:38:29

897 Views

To obscure a UITextField password in iOS, you can use the secureTextEntry property. This property allows you to hide the text entered into a text field by showing dots or asterisks instead of actual characters. In most iOS apps, we are required to obscure a UITextField to implement the password feature. This is easy to use the property. The isSecureTextEntry Property isSecureTextEntry is a property of the UITextField class in iOS that determines whether the text entered into the text field should be obscured, such as when entering a password. When isSecureTextEntry is set to true, the text entered into ... Read More

Make a VStack fill the width of the screen in SwiftUI

Nitin Aggarwal
Updated on 04-May-2023 10:43:38

17K+ Views

To make a VStack fill the screen width in SwiftUI, you can use the frame modifier with a maxWidth parameter set to ".infinity". In this article, you will see different examples of VStack with full width. VStack VStack is a layout container in SwiftUI that arranges views vertically in a top-to-bottom fashion. The views are stacked on top of each other, with the first view added to the VStack at the top and subsequent views added below it. In SwiftUI, VStack is part of a family of layout containers that also includes HStack and ZStack. These containers provide a flexible ... Read More

Swift Open Link in Safari in iOS Swift

Nitin Aggarwal
Updated on 04-May-2023 10:46:34

2K+ Views

In Swift, there are two ways to open a link. One approach is to use the UIApplication class to open a link in the Safari browser. Another approach is using the SafariServices framework in iOS. Let's see some examples of how to open a link based on these approaches. Approach 1: Using the UIApplication class Step 1 − Create a URL object for the link that you want to open. You can do this using the URL(string:) initializer. Step 2 − Create an instance of the UIApplication class. This class is responsible for managing the behavior of your app, ... Read More

How to change the background color of UIStackView?

Nitin Aggarwal
Updated on 04-May-2023 10:50:14

726 Views

In iOS, the UIStackView itself doesn't have a background color property. However, you can add a subview to the UIStackView and set its background color. In this example, we will add a stack view with some subviews. After that, we will see how to apply the background color to the stack view. UIStackView UIStackView is a container view that arranges its subviews horizontally or vertically. It automatically calculates the size and position of its subviews based on the stack view's axis, distribution, alignment, and spacing properties. You can add subviews to a UIStackView programmatically or in the Interface Builder. UIStackView ... Read More

Create a space at the beginning of a UITextField

Nitin Aggarwal
Updated on 04-May-2023 10:22:23

2K+ Views

To create space at the beginning of a UITextField in Swift, you can set the leftView property of the text field to a UIView with the desired width. By default, UITextField does not provide a margin on the left or right side and this is the most common requirement to have space for a better user interface. In this article, you will see an example of how to add a left margin to the text field. In this example, we first create a view controller and then an email address text field. First, we will see the default text field ... Read More

How do I open phone settings when a button is clicked in Swift?

Nitin Aggarwal
Updated on 04-May-2023 10:52:44

6K+ Views

In Swift, you can open the phone settings page with the click of a button. To open, you can use the UIApplication.shared.open() method. In Swift, you are able to use predefined expressions to open specific screens outside of the app. This predefined expression will help you to open the settings screen from your app. This is a very useful feature in iOS. Here is the Main Function if let url = URL(string:UIApplication.openSettingsURLString) { if UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url, options: [:], completionHandler: nil) } } Here's How This Code ... Read More

How to Know whether a Line Touches, Intersects or Lie Outside a Circle in Java?

Mr. Satyabrata
Updated on 04-May-2023 16:39:32

531 Views

A circle is a closed shape formed by tracing a point that moves in a plane such that its distance from a given point is constant. A line is a straight one-dimensional figure that does not have a thickness, and it extends endlessly in both directions. In this article we will check if a given line touches a circle or intersects it using java. We will be given with the centre coordinates and radius of a circle along with equation of the line. We need to check if the given line collides with the circle or not and hence three ... Read More

How to Know If Two Convex Regular Polygons have Same Centre or Not in Java?

Mr. Satyabrata
Updated on 04-May-2023 16:38:01

160 Views

A polygon is a 2-dimensional closed shape that has at least 3 sides. Depending on the number of sides, relationships of the sides and angles, and other characteristics, polygons can be classified under different names like triangles, squares, and quadrilaterals. The convex polygon definition explains that one is a polygon whose angles are all less than 180 degrees each. That also means that the vertices, the point where two sides meet, all point outward from the centre of the shape. In this article, we will find if two convex regular polygons have same centre or not. We will take two ... Read More

How to Confirm If Given Four Points Form a Square in Java?

Mr. Satyabrata
Updated on 04-May-2023 16:36:21

1K+ Views

A square is a two-dimensional shape which has four sides of equal length. The opposite sides of a square are parallel to each other and all four interior angles are right angles with diagonal of equal length. In this article we will check how to confirm if given four points form a square. We will be given a square with four points i.e. A, B, C, D as shown in the figure − We need to check from these points that if they form a square or not. To check this it should satisfy the following condition − ... Read More

Advertisements