swift

NSVisualEffectView with rounded corners

£可爱£侵袭症+ 提交于 2021-02-20 18:56:04
问题 How display a NSVisualEffectView with with rounded corners in OS X? My code to add my NSVisualEffectView: let visualEffectView = NSVisualEffectView(frame: NSMakeRect(0, 0, 300, 300)) visualEffectView.material = NSVisualEffectMaterial.Dark visualEffectView.blendingMode = NSVisualEffectBlendingMode.BehindWindow self.addSubview(visualEffectView) 回答1: You can enable layer backed views for your NSVisualEffectView by setting wantsLayer to true and then set the cornerRadius of the backing layer: let

NSVisualEffectView with rounded corners

情到浓时终转凉″ 提交于 2021-02-20 18:55:07
问题 How display a NSVisualEffectView with with rounded corners in OS X? My code to add my NSVisualEffectView: let visualEffectView = NSVisualEffectView(frame: NSMakeRect(0, 0, 300, 300)) visualEffectView.material = NSVisualEffectMaterial.Dark visualEffectView.blendingMode = NSVisualEffectBlendingMode.BehindWindow self.addSubview(visualEffectView) 回答1: You can enable layer backed views for your NSVisualEffectView by setting wantsLayer to true and then set the cornerRadius of the backing layer: let

How to get the index of a deleted row from a list in SwiftUI?

萝らか妹 提交于 2021-02-20 18:47:14
问题 I want to delete an element from an array that I am displaying as a list using a ForEach , but I also need to send a HTTP request to a REST API and I need to put the index of the element in the body of the request. Here is my code: ForEach(self.symptoms, id: \.self) { symptom in VStack(alignment: .leading) { Text(symptom) } }.onDelete(perform: delete) Here is the delete function: func delete(at offsets: IndexSet) { self.symptoms.remove(atOffsets: offsets) // here I want to make the HTTP

How to get the index of a deleted row from a list in SwiftUI?

坚强是说给别人听的谎言 提交于 2021-02-20 18:44:48
问题 I want to delete an element from an array that I am displaying as a list using a ForEach , but I also need to send a HTTP request to a REST API and I need to put the index of the element in the body of the request. Here is my code: ForEach(self.symptoms, id: \.self) { symptom in VStack(alignment: .leading) { Text(symptom) } }.onDelete(perform: delete) Here is the delete function: func delete(at offsets: IndexSet) { self.symptoms.remove(atOffsets: offsets) // here I want to make the HTTP

Enable Allow arbitrary Loads of App Transport Security Setting not working in XCODE 9.2 and iOS 11.2

孤街浪徒 提交于 2021-02-20 16:19:00
问题 I used same setting for enabling arbitrary load but now i faced some issues.I used alamofire for json parsing. info.plist settings: and error is : 回答1: your info plist hierarchy for transport should be like this 回答2: NSAppTransportSecurity provides the network layer security and only allow http secured urls. There are 2 ways to solve this: Case 1: In your code you are using an unsecure url with http:// replace it with https:// , then it will work. Case 2: If you don't have ssl enabled url

Enable Allow arbitrary Loads of App Transport Security Setting not working in XCODE 9.2 and iOS 11.2

岁酱吖の 提交于 2021-02-20 16:16:23
问题 I used same setting for enabling arbitrary load but now i faced some issues.I used alamofire for json parsing. info.plist settings: and error is : 回答1: your info plist hierarchy for transport should be like this 回答2: NSAppTransportSecurity provides the network layer security and only allow http secured urls. There are 2 ways to solve this: Case 1: In your code you are using an unsecure url with http:// replace it with https:// , then it will work. Case 2: If you don't have ssl enabled url

How do I keep a WKWebView object from crashing?

我怕爱的太早我们不能终老 提交于 2021-02-20 14:17:04
问题 Scenario I'm building an iOS application in Swift. One feature is to have a live video feed as the application background. The video feed is originating from a Raspberry Pi on a local network using sudo motion . Motion is successfully hosting the feed on default port 8081 . The Swift app has a WKWebView object with the source pointing to my Raspberry Pi's motion port. Suspected Issue The webpage at port 8081 is constantly refreshing to load the most recent frame from the camera. Problem When

How do I keep a WKWebView object from crashing?

拜拜、爱过 提交于 2021-02-20 14:08:43
问题 Scenario I'm building an iOS application in Swift. One feature is to have a live video feed as the application background. The video feed is originating from a Raspberry Pi on a local network using sudo motion . Motion is successfully hosting the feed on default port 8081 . The Swift app has a WKWebView object with the source pointing to my Raspberry Pi's motion port. Suspected Issue The webpage at port 8081 is constantly refreshing to load the most recent frame from the camera. Problem When

How do I keep a WKWebView object from crashing?

夙愿已清 提交于 2021-02-20 14:04:48
问题 Scenario I'm building an iOS application in Swift. One feature is to have a live video feed as the application background. The video feed is originating from a Raspberry Pi on a local network using sudo motion . Motion is successfully hosting the feed on default port 8081 . The Swift app has a WKWebView object with the source pointing to my Raspberry Pi's motion port. Suspected Issue The webpage at port 8081 is constantly refreshing to load the most recent frame from the camera. Problem When

How to get the name of an enumeration case by its raw value in Swift 4?

拈花ヽ惹草 提交于 2021-02-20 13:28:08
问题 Using Xcode 9.4.1 and Swift 4.1 Having an enumeration with multiple cases from type Int, how can I print the case name by its rawValue? public enum TestEnum : UInt16{ case ONE = 0x6E71 case TWO = 0x0002 case THREE = 0x0000 } I am accessing the Enum by the rawValue: print("\nCommand Type = 0x" + String(format:"%02X", someObject.getTestEnum.rawValue)) /*this prints: Command Type = 0x6E71 if the given Integer value from someObject.TestEnum is 28273*/ Now I additionally want to print "ONE" after