Category "swift"

Swift: Check which value in NSArray is closest to another given value

Lets say I have an array var values:[CGFloat] = [-12.0, 450, 300] I need to find out which of these numbers is closest to a given value, say var givenValue

What is the best/shortest way to convert a UIColor to hex (web color) in Swift?

I came up with the following solution, but would like to know if someone has a cleaner approach to it (tested it in Xcode-Playground): let colors = CGColorGetC

UItextView delegate swift - textViewDidBeginEditing not called

I've seen the other topics dealing with UITextView delegate, but can't seem to find where my issue come from. Here is my code, but when I modify my UITextView,

Cannot find type 'PiPViewCoordinator' in scope

I am getting following error when i install JitsiMeetSDK in flutter but i am unable to run app. Can somebody suggest me how can i resolve this issue? I am usin

How retrieve the normal for a given face of ARMeshGeometry?

given a ARMeshAnchor 'meshAnchor', i can retrieve its geometry and faces : let geometry = meshAnchor.geometry let faces = geometry.faces var i = Int(0) while i

DestinationViewController Segue and UINavigationController swift

So I have a prepareForSegue method like this: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "fromEve

How can I manage this view when constraints aren't available to me in swiftui?

I am very new to SwiftUI, and have actually been getting the hang of arranging my views using the Z, V and HStacks. But the lack of a centre anchor is proving d

SwiftUI edges visible after using overlay

I'm trying to create rounded edges in one of my views using overlay. .background(Color.gray.opacity(0.2)) .overlay( RoundedRectangle(cornerRadius: 10)

How can I present a small page sheet with SwiftUI?

I'm developing an app for iPad with SwiftUI. I want to present a page sheet but with a smaller size. I'm using but I can't change the width of the page sheet.

QLPreviewController missing navigation bar in SwiftUI

QLPreviewController navigation bar missing when I presented in sheet. It looks like this : How can I show up top navigation bar or navigationItem? QuickLook

Error while installing pod in Apple Silicon (M1)

Command i am running is brew install cocoapods Warning: cocoapods 1.11.2_2 is already installed and up-to-date. To reinstall 1.11.2_2, run: brew reinstall

How to underline a UILabel in swift?

How to underline a UILabel in Swift? I searched the Objective-C ones but couldn't quite get them to work in Swift.

How to prevent a UITableViewCell from moving (Swift 5)

This is actually a two part question. First take a look at the code: //canEditRowAt func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath)

SwiftUI: How to center a view vertically and horizontally inside of a container view and put something under it

I searched stackoverflow, but unfortunately didn't find a solution to this particular case. I try to display following scenario: a container view a Text that

XCTest: Wait for async call to finish in synchronous function

I have a synchronous function that calls an asynchronous sub function. Now I want to test that the synchronous function sets a property. I've seen many examples

How to create a delay in Swift?

I want to pause my app at a certain in point. In other words, I want my app to execute the code, but then at a certain point, pause for 4 seconds, and then cont

How to convert hexadecimal string to an array of UInt8 bytes in Swift?

I have the following code: var encryptedByteArray: Array<UInt8>? do { let aes = try AES(key: "passwordpassword", iv: "drowssapdrowssap") encrypt

Swift dictionary get key for value

I'm using a swift dictionary of type [UIImage:UIImage], and I'm trying to find a specific key for a given value. In Objective-C I could use allKeysForValue, bu

Rich notification play video clip

I'm trying to get rich notification and play video on the notification. I success to show an image and not found swift sample code. What need to be done to add

Render MKMapView offscreen

I'm trying to render an MKMapView into an UIImage, without showing it on the screen. I init the map: let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 1